UVA 1546 - Complete the sequence!(差分法)
来源:互联网 发布:java web小米商城项目 编辑:程序博客网 时间:2024/05/17 14:29
UVA 1546 - Complete the sequence!
题目链接
题意:给定多项式前s项,求出后c项,要求尽量小
思路:利用差分法,对原序列求s - 1次差分,就可以发现规律,然后对于每多一项,就逆推回去即可
代码:
#include <stdio.h>#include <string.h>const int N = 205;int t, s, c, a[N][N];int main() { scanf("%d", &t); while (t--) {scanf("%d%d", &s, &c);memset(a, 0, sizeof(a));for (int i = 0; i < s; i++) scanf("%d", &a[0][i]);for (int i = 1; i < s; i++) for (int j = 0; j < s - i; j++)a[i][j] = a[i - 1][j + 1] - a[i - 1][j];for (int i = 0; i < c; i++) { for (int j = s - 1; j >= 0; j--)a[j][s - j + i] = a[j + 1][s - j - 1 + i] + a[j][s - j - 1 + i]; printf("%d%c", a[0][s + i], (i == c - 1 ? '\n' : ' '));} } return 0;}
1 0
- UVA 1546 - Complete the sequence!(差分法)
- uva 1546 - Complete the sequence!(牛顿插值法)
- hdu1121 Complete the Sequence
- HDU 1121 Complete the Sequence
- 【HDU】 1121 Complete the Sequence
- HDU 1121 Complete the Sequence 数学题
- HDU1121——Complete the Sequence
- hdu 1121 Complete the Sequence(插值差分)
- 数论+差分 hdu1121 Complete the Sequence
- uva The Collatz Sequence
- The Hendrie Sequence UVA
- UVa 694 - The Collatz Sequence
- uva-694 - The Collatz Sequence
- UVa 694 The Collatz Sequence
- UVA 694 - The Collatz Sequence
- UVA 694 - The Collatz Sequence
- UVa 694 - The Collatz Sequence
- UVA - 694 - The Collatz Sequence
- BestCoder Round #1
- 紫外线消毒器:紫外线杀菌器产品特点
- CSS滤镜让图片模糊(毛玻璃效果)
- 每日风险投资速递(7月19-20日,8个投资/收购事件)
- jira修改日期格式
- UVA 1546 - Complete the sequence!(差分法)
- 07 内置对象
- 【详细教程】编译openwrt + njit-client 1.3 通过iNode认证
- CodeForces 1A
- int.class 和Integer.class不是相同的class对象
- VS2010版快捷键
- 基于spark_streaming的logistic流式机器学习
- C.5
- JSP简单练习-猜字母游戏