5 solutions

  • 4
    @ 2024-12-20 10:46:07
    #include<bits/stdc++.h>
    using namespace std;
    const int N=100;
    long long f[N]={0,1,2};//f[i]表示长度为i的长方形的方案数目 
    int main()
    {
    	int n;
    	cin>>n;
    	for(int i=3;i<=n;i++)
    	{
    		f[i]=f[i-1]+f[i-2];
    		//   竖着   横着 
    	}
    	cout<<f[n];
    	return 0;
    }
    
    • 4
      @ 2024-3-24 10:06:34
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          long long a,b,c;
          c=1,a=1,b=1;
          int n;
          cin>>n;
          for(int i =3;i<=n+1;i++)
          {
              c=a+b;
              a=b;
              b=c;
          }
          cout<<c;
          return 0;
      }
      //😅😅😅😅😅😅😅😅😅
      
      • 2
        @ 2025-1-20 9:21:16
        #include<bits/stdc++.h>
        using namespace std;
        const int N=100;
        long long f[N]={0,1,2};//f[i]表示长度为i的长方形的方案数目 
        int main()
        {
        	int n;
        	cin>>n;
        	for(int i=3;i<=n;i++)
        	{
        		f[i]=f[i-1]+f[i-2];
        		//   竖着   横着 
        	}
        	cout<<f[n];
        	return 0;
        }
        
        
        • 1
          @ 2026-11-1 10:31:37

          找规律专用

          #include<bits/stdc++.h>
          using namespace std;
          const int N=100;
          long long f[N]={0,1,2}; 
          int main()
          {   
          	int n;
          	cin>>n;
              for(int n=1;n<=10;n++){
                 for(int i=3;i<=n;i++)
          	{
          		f[i]=f[i-1]+f[i-2];
          		//   竖着   横着 
          	}
          	cout<<"2*"<<n<<"有"<<f[n]<<"种"<<endl; 
              }
          	
          	return 0;
          }
          
          • -1
            @ 2025-12-27 16:12:17
            
            【例】最长平台
            题目描述
            已知一个数组,这个数组的一个平台(Plateau)就是连续的一串值相同的元素,并且这一串元素不能再延伸。
            
            例如,在 1,2,2,3,3,3,4,5,5,6中1,2-2,3-3-3,4,5-5,6都是平台。
            
            试编写一个程序,接收一个数组,把这个数组最长的平台找出 来。
            
            在上面的例子中3-3-3就是最长的平台。
            
            输入
            第一行有一个整数
            n
            n,为数组元素的个数。
            
            第二行有
            n
            n个整数,整数之间以一个空格分开。
            
            输出
            输出最长平台的长度。
            
            输入数据 1
            10
            1 2 2 3 3 3 4 5 5 3
            输出数据 1
            3
            提示
            1
            ≤
            n
            ≤
            10
            5
            1≤n≤10 
            5
            
            • 1

            Information

            ID
            1257
            Time
            1000ms
            Memory
            256MiB
            Difficulty
            1
            Tags
            (None)
            # Submissions
            122
            Accepted
            47
            Uploaded By