Hydra_ @ 2017-07-23 20:52:31
#include<bits/stdc++.h>
int a[1100],b[1100],c[1100];
void jh()
{
for (int i=1;i<=1100-1;i++)
{
a[i]=b[i];
b[i]=c[i];
c[i]=a[i]+b[i];
if (c[i]>=10)
{
c[i]=c[i]-10;
c[i+1]++;
}
}
}
using namespace std;
int main()
{
int n;
cin>>n;
if (n==0)
{
cout<<0;
return 0;
}
if (n==1)
{
cout<<1;
return 0;
}
if (n==2)
{
cout<<2;
return 0;
}
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
b[1]=1;c[1]=2;
for (int i=3;i<=n;i++)
jh;
int o=0;
for (int i=1100-1;c[i]==0;i--)
o=i;
for (int j=o-1;j>=1;j--)
cout<<c[j];
return 0;
}
by Simpson561 @ 2017-11-02 10:11:57
jh后面要加括号的,要不然就CE了