poj 3982- 序列-大整数加法
来源:互联网 发布:英特尔双核处理器优化 编辑:程序博客网 时间:2024/05/16 17:35
B - 序列
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uDescription
数列A满足An = An-1 + An-2 + An-3, n >= 3
编写程序,给定A0, A1 和 A2, 计算A99
编写程序,给定A0, A1 和 A2, 计算A99
Input
输入包含多行数据
每行数据包含3个整数A0, A1, A2 (0 <= A0, A1, A2 <= 32767)
数据以EOF结束
每行数据包含3个整数A0, A1, A2 (0 <= A0, A1, A2 <= 32767)
数据以EOF结束
Output
对于输入的每一行输出A99的值
Sample Input
1 1 1
Sample Output
69087442470169316923566147
#include <stdio.h>#include <string.h>#define TT 106int a[TT], b[TT], c[TT];void solve(){int TIME = 99;while (TIME -- ){for (int i=0; i<TT; ++i){a[i] += b[i] + c[i];if (a[i] > 9){ a[i+1] += a[i] / 10;a[i] %= 10;}}for (int i=0; i<TT; ++i){int tmp = a[i];a[i] = b[i];b[i] = c[i];c[i] = tmp;}}TIME = TT;while (!a[TIME--]);for (int i=TIME+1; i>=0; --i)printf("%d", a[i]);printf("\n");}void init(int x, int y, int z){memset(a, 0, sizeof(a));memset(b, 0, sizeof(b));memset(c, 0, sizeof(c));int i=0;while (x > 0){a[i++] = x % 10;x /= 10;}i = 0;while (y > 0){b[i++] = y % 10;y /= 10;}i = 0;while (z > 0){c[i++] = z % 10;z /= 10;}}int main(){int x, y, z;while (~scanf("%d%d%d", &x, &y, &z)){init(x, y, z);solve();}return 0;}
- poj 3982- 序列-大整数加法
- POJ-1503-大整数加法
- Poj 2981:大整数加法
- poj 1503 大整数高精度 加法
- poj 大整数加法 http://poj.grids.cn/problem/2981/
- 大整数加法
- 大整数加法
- 高精度 大整数加法
- 大整数加法
- 大整数加法
- 大整数加法
- 大整数加法
- 大整数加法计算
- zoj1292大整数加法
- 大整数加法
- 大整数加法
- 大整数加法函数
- 大整数加法
- 日语训读
- Canopen通讯规范DS301_V4.02学习研究——前6章基础知识
- 《精通Oracle10gPLSQL编程》12、开发包
- 滑动菜单 SlidingMenu (转载)
- Install GNOME development environment on Ubuntu
- poj 3982- 序列-大整数加法
- session sniffer
- pwsniffer
- 我的面试经历
- A bit of fun: fun with bits
- 如果让我重做一次研究生--王泛森院士
- 计算一个 32 位无符号整数有多少个位为 1
- webservice的原理及概念
- 绩效考核