hdu Isting

来源:互联网 发布:相册mv制作软件 编辑:程序博客网 时间:2024/05/23 18:34
#include<stdio.h>
#include<string.h>
int main()
{
char se[250];
int i,j,n;
int f[250][1000]={0};
f[0][1]=f[1][1]=1;
for(i=2;i<250;i++)       //打表,反向存,每个位置是个小于十的数值
{
for(j=1;j<=1000;j++)
f[i][j]=f[i-2][j]+f[i-1][j];
for(j=1;j<=1000;j++)
{
f[i][i+1]+=f[i][j]/10;     //求余
f[i][j]%=10;
}
}
scanf("%d",&n);
while(n--)
{
scanf("%s",se);
j=1000;
while(f[strlen(se)][j]==0)--j;        //直到不为0才计数
for(;j>=1;j--)
printf("%d",f[strlen(se)][j]);  // 反向输出
printf("\n");
}
return 0;
}
原创粉丝点击