站长!为什么错了!

tctm340 2024-09-16 20:34:53 13

#include<bits/stdc++.h> using namespace std; int n; int a; int shu(int x){ if(x==1){ return 1; } else if(x==2){ return 1; } else return shu(x-1)+shu(x-2); } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a; cout<<shu(a)<<endl; } return 0; }

{{ vote && vote.total.up }}

共 1 条回复

root 站长

应该是超时了吧,用数组保存所有的结果,输入一个n,直接输出f[n]