3 条题解

  • 0
    @ 2024-3-16 15:08:49
    • #include <bits/stdc++.h>
      using namespace std; 
      int x;
      int a[35];
      int main(){
      	while(cin >> x){
      		a[1] = 1;
      		a[2] = 2;
      		for(int i=3;i<=x;i++){
      			a[i]=a[i-1]+a[i-2];
      		} 
      		cout << a[x] << endl;
      	}
      	return 0;
      }
      

      Copy

    • 0
      @ 2024-2-22 20:13:07
      #include <bits/stdc++.h>
      using namespace std; 
      int x;
      int a[35];
      int main(){
      	while(cin >> x){
      		a[1] = 1;
      		a[2] = 2;
      		for(int i=3;i<=x;i++){
      			a[i]=a[i-1]+a[i-2];
      		} 
      		cout << a[x] << endl;
      	}
      	return 0;
      }
      
      • -1
        @ 2024-4-10 16:31:08
        #include<bits/stdc++.h>
        using namespace std;
        int n;
        int a[35];
        int f(int x)
        {
        	if(x==1)
        		return 1;
        	if(x==2)
        		return 2;
        	return f(x-1)+f(x-2);
        } 
        int main()
        {
        	while(cin>>n){
        		cout<<f(n)<<endl;
        	}
        	return 0;
        }
        
        • 1

        信息

        ID
        1369
        时间
        1000ms
        内存
        128MiB
        难度
        2
        标签
        (无)
        递交数
        55
        已通过
        34
        上传者