Poj 2583 Series Determination

1.Link:

http://poj.org/problem?id=2583

2.Content:

Series Determination

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6215   Accepted: 4090

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).

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

Source

South Central USA 2003

3.Method:

4.Code:

 1 #include <iostream>
 2 #include <cstdio>
 3
 4 using namespace std;
 5
 6 int main()
 7 {
 8     double x,y,z;
 9     double a,b,c;
10     double p,q,r;
11     while(cin>>x>>y>>z)
12     {
13         a=(z-2*y+x)/2;
14         b=2*y-3*x/2-z/2;
15         c=x;
16         //cout<<a<<" "<<b<<" "<<c<<endl;
17         p=a*3*3+b*3+c;
18         q=a*4*4+b*4+c;
19         r=a*5*5+b*5+c;
20         printf("%.0lf %.0lf %.0lf\n",p,q,r);
21     }
22     //system("pause");
23     return 0;
24 }

5.Reference:

时间: 2024-12-28 04:26:36

Poj 2583 Series Determination的相关文章

Series Determination

题目描述 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 wan

POJ 2583

1 #include<iostream> 2 #include<stdio.h> 3 using namespace std; 4 5 int main() 6 { 7 //freopen("acm.acm","r",stdin); 8 int f_0; 9 int f_1; 10 int f_2; 11 while(cin>>f_0>>f_1>>f_2) 12 { 13 cout<<3*f_2

HOJ 题目分类

转自:http://blog.sina.com.cn/s/blog_65f3869301011a1o.html ******************************************************************************* 简单题(包括枚举,二分查找,(复杂)模拟,基础数据结构(栈.队列),杂题等 ****************************************************************************

POJ 3233 - Matrix Power Series ( 矩阵快速幂 + 二分)

POJ 3233 - Matrix Power Series ( 矩阵快速幂 + 二分) #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long LL; #define MAX_SIZE 30 #define CLR( a, b ) memset( a, b, sizeof(a) ) int MOD = 0; int n, k; st

POJ 3233 Matrix Power Series (矩阵快速幂+二分)

Matrix Power Series Time Limit: 3000MS   Memory Limit: 131072K Total Submissions: 16403   Accepted: 6980 Description Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + - + Ak. Input The input contains exactly one test cas

矩阵十点【两】 poj 1575 Tr A poj 3233 Matrix Power Series

poj 1575  Tr A 主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1575 题目大意:A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973. 数据的第一行是一个T,表示有T组数据. 每组数据的第一行有n(2 <= n <= 10)和k(2 <= k < 10^9)两个数据.接下来有n行,每行有n个数据,每一个数据的范围是[0,9].表示方阵A的内容. 一个矩阵高速幂的裸题. 题解: #

Poj 3233 Matrix Power Series(矩阵二分快速幂)

题目链接:http://poj.org/problem?id=3233 解题报告:输入一个边长为n的矩阵A,然后输入一个k,要你求A + A^2 + A^3 + A^4 + A^5.......A^k,然后结果的每个元素A[i][j] % m.(n <= 30,k < 10^9,m < 10^4) 要用到矩阵快速幂,但我认为最重要的其实还是相加的那个过程,因为k的范围是10^9,一个一个加肯定是不行的,我想了一个办法就是我以k = 8为例说明: ans = A + A^2 + A^3 +

poj 3233 Matrix Power Series(等比矩阵求和)

http://poj.org/problem?id=3233 ps转: 用二分方法求等比数列前n项和:即 原理: (1)若n==0 (2)若n%2==0     (3)若n%2==1 代码如下: LL sum(LL p,LL n) { if(n==0) return 1; if(n&1) return (1+pow(p,(n>>1)+1))*sum(p,n>>1); else return (1+pow(p,(n>>1)+1))*sum(p,(n-1)>&

[ACM] POJ 3233 Matrix Power Series (求矩阵A+A^2+A^3...+A^k,二分求和)

Matrix Power Series Time Limit: 3000MS   Memory Limit: 131072K Total Submissions: 15417   Accepted: 6602 Description Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + - + Ak. Input The input contains exactly one test cas