HDU1121——Complete the Sequence
来源:互联网 发布:mac装win10声卡驱动 编辑:程序博客网 时间:2024/05/02 14:11
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1121
题目大意:给你一串有规律的数,让你写出后面C个。
别人都说是差分,但我是根据直觉来做这道题的,因为以前学过等差数列和等比数列,和这有差不多的性质,结果真的一样。就这么递推出来了。其实当你看到第三组样例时,也同样能找出答案。
0 1 2 3 4 5 6 7 8 9
-------------------------------
0 1 1 1 1 1 1 1 1 1 2 11 56
1 0 0 0 0 0 0 0 0 1 9 45
2 0 0 0 0 0 0 0 1 8 36
3 0 0 0 0 0 0 1 7 28
4 0 0 0 0 0 1 6 21
5 0 0 0 0 1 5 15
6 0 0 0 1 4 10
7 0 0 1 3 6
8 0 1 2 3
9 1 1 1
#include<iostream>#include<cstdio>using namespace std;int main(){ int T; int a[110][110]; scanf("%d",&T); while(T--) { int i,j,s,c; scanf("%d%d",&s,&c); for(i=1;i<=s;i++) scanf("%d",&a[1][i]); for(i=2;i<=s;i++) for(j=s-1;j>=1;j--) a[i][j]=a[i-1][j+1]-a[i-1][j]; /*for(i=1;i<=s;i++) { for(j=1;j<=s-i+1;j++) printf("%d ",a[i][j]); cout<<endl; }*/ for(i=2;i<=c+1;i++) a[s][i]=a[s][1]; for(i=s-1;i>=1;i--) { int t=s-i+1+c; for(j=s-i+2;j<=t;j++) a[i][j]=a[i][j-1]+a[i+1][j-1]; } /*for(i=1;i<=s+c;i++) { for(j=1;j<=s+c-i+1;j++) printf("%d ",a[i][j]); cout<<endl; }*/ for(i=s+1;i<=s+c-1;i++) printf("%d ",a[1][i]); printf("%d\n",a[1][s+c]); } return 0;}
0 0
- HDU1121——Complete the Sequence
- hdu1121 Complete the Sequence
- 数论+差分 hdu1121 Complete the Sequence
- HDU 1121 Complete the Sequence
- 【HDU】 1121 Complete the Sequence
- UVA 1546 - Complete the sequence!(差分法)
- uva 1546 - Complete the sequence!(牛顿插值法)
- HDU 1121 Complete the Sequence 数学题
- hdu 1121 Complete the Sequence(插值差分)
- 读书摘要—C++:The Complete Reference
- hdu 1121 Complete the Sequence(DP多项式差分)
- 杭电ACM HDU 1121 Complete the Sequence
- HDU 1211 Complete the Sequence(差分方法)
- POJ - Complete the Sequence! - 生成完整序列数
- hdu 1121 差分计算 Complete the Sequence
- Code Complete ----------- (Note 1—— Laying the foundation)
- UESTC 1817——Complete Building the Houses 贪心
- HAPPY训练赛——Complete the Word
- 支持向量机通俗导论(理解SVM的三层境界)
- artDialog实现弹窗
- EA
- 关于mini2440蓝牙驱动BLUEZ的移植
- 【BZOJ 1913】 [Apio2010]signaling 信号覆盖
- HDU1121——Complete the Sequence
- redis设置访问密码
- IOS学习——BLOCK
- android PathData生成问题
- Android学习笔记(7)——数据库Sqlite的使用
- MATLAB下图示化符号计算器的使用
- HDU 2604 Queuing (矩阵快速幂)
- 普及1080i和1080p的区别
- ios开发,javascript->OC