jcjkyx110507 @ 2023-12-19 16:17:06
#include<bits/stdc++.h>
const int maxn=35;
long long f[maxn];
int main(){
int n;
scanf("%d",&n);
if(n==0) {cout<<"0";return 0;}
f[1]=1,f[2]=2;
for(int i=3;i<=n;i++)
f[i]=f[i-1]+f[i-2];
printf("%lld",f[n]);
return 0;
}
by Ahws_rwhy @ 2023-12-19 16:19:33
using namespace std;
没了。。
by Ahws_rwhy @ 2023-12-19 16:19:41
@jinzhilong
by jcjkyx110507 @ 2023-12-19 16:25:45
出现紫测试点@rwhy
by Ahws_rwhy @ 2023-12-19 16:26:23
@jinzhilong 数组开大点(1000)
by jcjkyx110507 @ 2023-12-19 16:34:15
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000;
long long f[maxn];
int main(){
int n;
scanf("%d",&n);
if(n==0) {cout<<"0";return 0;}
f[1]=1,f[2]=2;
for(int i=3;i<=n;i++)
f[i]=f[i-1]+f[i-2];
printf("%lld",f[n]);
return 0;
}
@rwhy
by jcjkyx110507 @ 2023-12-19 16:35:05
红紫杂交
by jcjkyx110507 @ 2023-12-19 16:35:36
@rwhy
by xiaoshumiao @ 2023-12-19 16:36:16
@jinzhilong
数组要开 5000。
此题需要高精度。
by Ahws_rwhy @ 2023-12-19 16:41:08
@jinzhilong 口误 5000 以上。。。
by Ahws_rwhy @ 2023-12-19 16:41:54
@jinzhilong 60 分。