好惨啊!弄了我这么久...
还好最后AC了
#include<cstdio>
int n;
int tot=0;
int ans[25000];
int main()
{
long long t0,t1=1,t2=1;
for (int i=3;tot<22000;i++)
{
t0=t1+t2;
t2=t1;
t1=t0;
if (t0>=1e18)
{
t0/=10;
t1/=10;
t2/=10;
}
bool p=true;
for (int j=2;j*j<=i;j++)
if (i%j==0)
{
p=false;
break;
}
if (p || i==4)
{
long long p=t0;
while (p>=1e9) p/=10;
ans[++tot]=p;
}
}
while (scanf("%d",&n)==1) printf("%d\n",ans[n]);
return 0;
}
还好最后AC了
#include<cstdio>
int n;
int tot=0;
int ans[25000];
int main()
{
long long t0,t1=1,t2=1;
for (int i=3;tot<22000;i++)
{
t0=t1+t2;
t2=t1;
t1=t0;
if (t0>=1e18)
{
t0/=10;
t1/=10;
t2/=10;
}
bool p=true;
for (int j=2;j*j<=i;j++)
if (i%j==0)
{
p=false;
break;
}
if (p || i==4)
{
long long p=t0;
while (p>=1e9) p/=10;
ans[++tot]=p;
}
}
while (scanf("%d",&n)==1) printf("%d\n",ans[n]);
return 0;
}