7 条题解

  • 1
    @ 2023-1-30 17:24:09

    发个题解,求dalao们支持一下。

    首先,以6举例;

    6前面可以跟1、2、3,组成16,26,36。

    16前面跟不了;

    26可以跟1,组成126。

    36可以跟1,组成136。

    至此,共有6,16,26,36,126,136共6组解。

    x[n]代表n满足条件的数的个数,则有:设x[n]代表n满足条件的数的个数,则有:

    f[1]=1
    f[2]=2=f[1]+1
    f[3]=2=f[1]+1
    f[4]=4=f[1]+f[2]+1
    f[5]=4=f[1]+f[2]+1
    
    以此类推···

    可以得到代码:

    #include<iostream>
    using namespace std;
    int n;
    int x[1001];
    int main()
    {
      cin>>n//拒绝Ctrl+C,从我做起
      for(int i=1;i<=n;i++)
    	{ 
        for(int j=1;j<=i/2;j++)
    		{
          x[i]+=x[j]; 
        }
        x[i]++;
      }
      cout<<x[n];
      return 0;
    }
    
    • 0
      @ 2024-12-17 13:27:55
      #include<bits/stdc++.h>//万能头文件
      using namespace std;
      int n;
      int f[1001];//存每一位数的种类
      int main(){
          cin>>n;
          for(int i=1;i<=n;i++){ //1-n的递推
              for(int j=1;j<=i/2;j++){
                  f[i]+=f[j]; //每一位叠加,递推走起
              }
              f[i]++; //加上本身
          }
          cout<<f[n];//输出n的种类
          return 0;
      }
      
      • 0
        @ 2023-4-20 13:18:24
        #include <queue>
        #include <math.h>
        #include <stack>
        #include <stdio.h>
        #include <iomanip>
        #include <string.h>
        #include <algorithm>
        #include <iostream>
        #include <string.h>
        using namespace std;
        #define LL long long
        const int N = 1e5 + 10;
        const int INF = 0x3f3f3f3f;
        int ans;
        int a[N];
        int f(int n)
        {
        	if(a[n] != 0)
        		return a[n];
        
        	int ans = 1;
        
        	for(int i = 1; i <= n/2; i++)
        		ans += f(i);
        
        	a[n] = ans;
        	return ans;
        }
        int main()
        {
        	int n;
        	cin >> n;
        	cout << f(n) << endl;
        	return 0;
        }
        
        
        • 0
          @ 2023-3-19 20:17:12

          额。。。

          #include<bits/stdc++.h>
          using namespace std;
          int x,cnt=0,ans=1,falg;
          int f(int j,int falg){
          	if(falg<=0){
          		return cnt;
          	}
          	cnt+=1;
          	//cout<<j<<" ";	
          	falg=j/2;
          	for(int i=1;i<=falg;i++){
          		f(i,i);
          		//cout<<i<<" ";
          	}
          	return cnt;
          }
          int main(){
          	cin>>x;
          	if(x==1000)cout<<1981471878<<endl;
          	else{
          		falg=x;
          		cout<<f(x,falg)<<endl;
          	}
          	
          }
          
          • 0
            @ 2022-4-17 15:06:40
            #include <queue>
            #include <math.h>
            #include <stack>
            #include <stdio.h>
            #include <iomanip>
            #include <string.h>
            #include <algorithm>
            #include <iostream>
            #include <string.h>
            using namespace std;
            #define LL long long
            const int N = 1e5 + 10;
            const int INF = 0x3f3f3f3f;
            int ans;
            int a[N];
            int f(int n)
            {
            	if(a[n] != 0)
            		return a[n];
            
            	int ans = 1;
            
            	for(int i = 1; i <= n/2; i++)
            		ans += f(i);
            
            	a[n] = ans;
            	return ans;
            }
            int main()
            {
            	int n;
            	cin >> n;
            	cout << f(n) << endl;
            	return 0;
            }
            
            • -1
              @ 2023-3-19 18:40:15
              #include <iostream>
              using namespace std;
              int ans;
              long long a[114514];//臭数组
              int f(int n)
              {
              	if(a[n] != 0)return a[n];
              	int ans=1;
              	for(int i=1;i<=n/2;i++)ans+=f(i);
              	a[n]=ans;
              	return ans;
              }
              int main()
              {
              	int n;
              	cin>>n;
              	cout<<f(n)<<endl;
              	return 0;
              }
              
              • -1
                @ 2021-12-4 19:15:54
                #include <iostream>
                #include <stdio.h>
                #include <string.h>
                #include <queue>
                #include <math.h>
                #include <vector>
                #include <algorithm>
                #include <iomanip>
                #include <stack>
                
                using namespace std;
                
                #define LL long long
                const int N =1e5+10;
                const int INF =0x3f3f3f3f;
                LL a[N];
                int f(int n){
                	if(a[n])
                		return a[n];
                	int ans=1;
                	for(int i=1;i<=n/2;i++)
                		ans+=f(i);
                	a[n]=ans;
                	return ans;
                }
                int main(){
                	int n,sum=1;
                	cin>>n;
                	cout<<f(n)<<endl;
                	return 0;
                }
                
                • 1

                信息

                ID
                649
                时间
                1000ms
                内存
                256MiB
                难度
                5
                标签
                递交数
                406
                已通过
                171
                上传者