哈理工1009 由已知数据求方程组

Series Determination
Time Limit: 1000 MS Memory Limit: 65536 K
Description
Boudreaux and Thibodeaux aren't very good at math, so they need you to write a program that can determine the second degree polynomial used to generate a given sequence of three integers. As proof that you've figured out the polynomial, they want your program to print out the next 3 integers in the sequence.
You know that each sequence is generated by a polynomial of the form f(x) = Ax2 + Bx + C, where A, B, and C are integers in the range (-103 <= (A, B, C) <= 103). You are given the values f(0), f(1), f(2) and are to determine the values f(3), f(4), f(5).
Input
Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets.
Each data set consists of a single line containing the space-separated integer values of the polynomial evaluated at 0, 1, and 2 (in that order). These values will be in the range (-103 <= (f(0), f(1), f(2)) <= 103).

Process to the end of file.

Output
For each data set, there will be exactly one line of output containing the space-separated integer values of the polynomial evaluated at 3, 4, and 5 (in that order). These values will be in the range (-104 <= (f(3), f(4), f(5)) <= 104).
Sample Input
0 0 0 1 1 1 1 2 3 0 1 4 0 2 8
Sample Output
0 0 0 1 1 1 4 5 6 9 16 25 18 32 50
题意为根据数求方程组
c=x1 
a+b+c=x2
4a+2b+c=x3
解以上方程组得:
c=x1;
a=(x3-2*x2+x1)/2;
b=x2-a-c;
 1 #include<stdio.h>
 2 int main()
 3 {
 4     int x1,x2,x3,a,b,c;
 5     while(scanf("%d%d%d",&x1,&x2,&x3)!=EOF)
 6     {
 7       c=x1;
 8       a=(x3-2*x2+x1)/2;
 9       b=x2-a-c;
10       printf("%d ",9*a+3*b+c);
11       printf("%d ",16*a+4*b+c);
12       printf("%d\n",25*a+5*b+c);
13     }
14      return 0;
15 }

 

即可解决问题
posted @ 2012-12-07 18:49  孤独是一种力量  阅读(221)  评论(0编辑  收藏  举报