Hat's Fibonacci
来源:互联网 发布:python sys.path 编辑:程序博客网 时间:2024/04/29 01:18
Problem Description
A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1.
F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)
Your task is to take a number as input, and print that Fibonacci number.
F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)
Your task is to take a number as input, and print that Fibonacci number.
Input
Each line will contain an integers. Process to end of file.
Output
For each case, output the result in a line.
Sample Input
100
Sample Output
4203968145672990846840663646/*解题报告:对大数的加法一段一段的加,也就是每8位看成一个整形的数(mod 10^9),进行整数加法。*///标程:#include<stdio.h>#include<string.h>#define N 10000#define M 300#define pi 100000000int f[N][M];void fun(){ int i,j; memset(f,0,sizeof(f));f[1][1]=f[2][1]=f[3][1]=f[4][1]=1;int k;for(i=5;i<N;i++){k=0;for(j=1;j<M;j++){k=k+f[i-1][j]+f[i-2][j]+f[i-3][j]+f[i-4][j]; f[i][j]=k%pi; k=k/pi;}}}int main(){/// freopen("a.txt","r",stdin);fun();int n,i,j;while(scanf("%d",&n)!=EOF){ for(i=M-1;i>0;i--) if(f[n][i]!=0) break; printf("%d",f[n][i]); for(j=i-1;j>0;j--) printf("%08d",f[n][j]); printf("\n");}return 0;}
0 0
- Hat's Fibonacci hdu1250
- Hat's Fibonacci
- 1250 Hat's Fibonacci
- Hat's Fibonacci
- hdu1250-Hat's Fibonacci
- hdu1250-Hat's Fibonacci
- HDU1250:Hat's Fibonacci
- hdu1250 Hat's Fibonacci
- Hat's Fibonacci
- Hat's Fibonacci
- Hat's Fibonacci
- HDU1250 Hat's Fibonacci
- Hat's Fibonacci
- Hat's Fibonacci
- Hat's Fibonacci
- hdu1250 Hat's Fibonacci
- Hat's Fibonacci
- hdu 1250 Hat's Fibonacci
- C语言面试宝典题目分析(四)
- Android Studio中加载.so库文件方法
- .git目录剖析
- 题目1470:调整方阵
- Android 通过网页链接打开本地应用
- Hat's Fibonacci
- 题目1549:货币问题
- shell中的函数定义及控制语句
- Tcp客服端并发访问服务器
- 扫读浏览
- include 指令
- JSTL基本标签一 ForEach
- 深圳市有关事假、病假、婚假、丧假、产假、哺乳假、生育看护假的规定
- Linux和Windos双系统安装分区方法