uva 1546 - Complete the sequence!(牛顿插值法)
来源:互联网 发布:怎么进淘宝卖家中心 编辑:程序博客网 时间:2024/05/22 02:29
题目连接:uva 1546 - Complete the sequence!
题目大意:给出一个序列的n项,求满足序列规律的后c项,要求尽量小。
解题思路:牛顿插值法,每次求两项之间的差,形成一个新的序列,直到序列公差为0时,回带回原来的序列即可。
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 205;int S, C, arr[maxn][maxn];int main () { int cas; scanf("%d", &cas); while (cas--) { scanf("%d%d", &S, &C); for (int i = 0; i < S; i++) scanf("%d", &arr[0][i]); for (int i = 1; i < S; i++) { for (int j = 0; j < S - i; j++) arr[i][j] = arr[i-1][j+1] - arr[i-1][j]; } for (int i = 1; i <= C; i++) arr[S-1][i] = arr[S-1][0]; for (int i = S-2; i >= 0; i--) { int pos = S - i; for (int j = 0; j < C; j++) arr[i][j+pos] = arr[i+1][j+pos-1] + arr[i][j+pos-1]; } printf("%d", arr[0][S]); for (int i = 1; i < C; i++) printf(" %d", arr[0][S+i]); printf("\n"); } return 0;}
0 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 10428 - The Roots(牛顿迭代法)
- uva 10428 - The Roots(牛顿迭代法)
- UVa 10428 The Roots,牛顿迭代法
- UVa 694 - The Collatz Sequence
- uva-694 - The Collatz Sequence
- UVa 694 The Collatz Sequence
- UVA 694 - The Collatz Sequence
- Codeforces 38G Queue 伸展树
- 【java基础】[数组]
- Java进阶之欧拉工程 第十四篇【 最长的collatz序列】
- 数据结构:堆
- Adapter——notifyDataSetChanged
- uva 1546 - Complete the sequence!(牛顿插值法)
- 关于STM32中RTC的校准方法
- 【DataStrcutre】Introduction and description of Binary Trees
- HDOJ 题目2973 YAPTCHA(数学,威尔逊定理)
- HT图形组件设计之道(三)
- PAT 1043. Is It a Binary Search Tree (25)
- Cocos2d-x层(Layer)动画的实现
- 记一些琐碎的东西
- Scala学习笔记