2 条题解

  • 0
    @ 2025-10-18 19:18:07

    #include<bits/stdc++.h> #define ll long long using namespace std; long long n,f[51]; int main(){ cin>>n; f[1]=f[2]=1; for(int i=3;i<=n;i++)f[i]=f[i-1]+f[i-2]; cout<<f[n]; return 0; }

    • -1
      @ 2025-7-2 19:27:42
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
      	long long k,a1,a2,b,s=1;
      	cin>>k;
          while(s==1){
      	if(k<=2)cout<<1;
          else if(k>=3){
          a1=1;
      	a2=1;
      	b=0;
      	for(int i=2;i<k;i++){
      		b=a1+a2;
      		a1=a2;
      		a2=b;
      	} 
      cout<<b;	 
      }
      s++;
      }
      	return 0;
      	}
      
      • 1

      信息

      ID
      342
      时间
      1000ms
      内存
      256MiB
      难度
      3
      标签
      (无)
      递交数
      46
      已通过
      27
      上传者