加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

NYOJ 114 某种序列【大数】

发布时间:2020-12-14 02:46:26 所属栏目:大数据 来源:网络整理
导读:http://acm.nyist.net/JudgeOnline/problem.php?pid=114 #includestdio.h#includestring.h#define base 100000000int a[100][100];void f(int i,int n){a[i][1]=n;}int main(){int i,j,len,t1,t2,t3,temp,jw;while(~scanf("%d%d%d",t1,t2,t3)){if(t1==0t2==0


http://acm.nyist.net/JudgeOnline/problem.php?pid=114


#include<stdio.h>
#include<string.h>
#define base 100000000
int a[100][100];

void f(int i,int n)
{
	a[i][1]=n;
}

int main()
{
	int i,j,len,t1,t2,t3,temp,jw;
	while(~scanf("%d%d%d",&t1,&t2,&t3))
	{
		if(t1==0&&t2==0&&t3==0)
			printf("0");
		else
		{
			memset(a,sizeof(a));
			f(0,t1);
			f(1,t2);
			f(2,t3);//转为数组存数
			len=1;
			
			for(i=3;i<=99;i++)
			{
				jw=0;
				for(j=1;j<=len;j++)
				{
					temp=a[i-1][j]+a[i-2][j]+a[i-3][j]+jw;
					a[i][j]=temp%base;
					jw=temp/base;
					if(j == len && jw != 0)
					len++;
				}
			}
			i=len;
			printf("%d",a[99][i--]);
			for(;i>=1;i--)
			printf("%08d",a[99][i]);
		}
		printf("n");
	}
	return 0;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读