7 条题解

  • 1
    @ 2025-11-30 15:38:23

    包AC,我老师教的,错了找我老师

    #include<bits/stdc++.h>
    #define ll long long
    using namespace std;
    ll f[25][25][25],vis[25][25][25];
    ll w(ll a,ll b,ll c){
    	if(a<=0||b<=0||c<=0)return 1;
    	if(a>20||c>20||b>20)return w(20,20,20);;
    	if(vis[a][b][c]!=0)return f[a][b][c];
    	vis[a][b][c]=1;
    	if(a<b&&b<c)return f[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    	return f[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
    }
    int main(){
    	ll a,b,c;
    	while(true){
    		cin>>a>>b>>c;
    		if(a==-1&&b==-1&&c==-1){
    			break;
    		}
    		cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<w(a,b,c)<<endl;
    	}
    	return 0;
    }
    
    • 1
      @ 2025-5-16 18:26:46
      #include <bits/stdc++.h>
      using namespace std;
      long long f[30][30][30];
      long long w(long long a,long long b,long long c){
      	if(a<=0 || b<=0 || c<=0)return 1;
      	
      	if(a>20 || b>20 || c>20)return w(20,20,20);
      	
      	if(f[a][b][c]!=0) return f[a][b][c];
      	
      	if(a<b && b<c) f[a][b][c] = w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
      	
      	else f[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
      	
      	return f[a][b][c];
      }
      int main(){
      	long long a,b,c;
      	while(cin >> a >> b >>c){
      		if (a==-1&&b==-1&&c==-1)return 0;
      		cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<< w(a,b,c)<<endl;
      	
      		
      	}
      	return 0;
      }
      
      
      
      • 1
        @ 2025-5-16 18:25:17
        #include <bits/stdc++.h>
        using namespace std;
        long long f[30][30][30];
        long long w(long long a,long long b,long long c){
        	if(a<=0 || b<=0 || c<=0)return 1;
        	
        	if(a>20 || b>20 || c>20)return w(20,20,20);
        	
        	if(f[a][b][c]!=0) return f[a][b][c];
        	
        	if(a<b && b<c) f[a][b][c] = w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
        	
        	else f[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
        	
        	return f[a][b][c];
        }
        int main(){
        	long long a,b,c;
        	while(cin >> a >> b >>c){
        		if (a==-1&&b==-1&&c==-1)return 0;
        		cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<< w(a,b,c)<<endl;
        	
        		
        	}
        	return 0;
        }
        
        
        
        • 0
          @ 2023-5-10 20:31:24
          #include <stdio.h>
          #include <string.h>
          #include <queue>
          #include <math.h>
          #include <vector>
          #include <algorithm>
          #include <iomanip>
          #include <stack>
          using namespace std;
          long long num[30][30][30];
          long long w(int a,int b,int c){
          	long long ans =0;
          	if(a<=0 || b<=0 || c<=0)return 1;
          	if(a>20 || b>20 || c>20)return w(20,20,20);
          	if(num[a][b][c]) return num[a][b][c];
          	if(a<b && b<c) ans = w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
          	else ans=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
          	num[a][b][c]=ans;
          	return ans;
          }
          int main(){
          	long long a,b,c;
          	while(cin >> a >> b >>c){
          		if (a==-1&&b==-1&&c==-1)return 0;
          		printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,w(a,b,c)); 
          	
          		
          	}
          	return 0;
          }//更简单
          
          • -1
            @ 2023-4-20 13:22:12
            #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 num [30][30][30];
            LL w(int a , int b , int c){
            	if(a<=0||b<=0||c<=0)
            		return 1; 
            	if(a>20||b>20||c>20)
            		return w(20,20,20);
            	if(num [a][b][c])
            		return num [a][b][c];
            	LL ans=0;
            	if(a<b&&b<c)
            		ans= w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
            	else
            		ans= w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
            	num [a][b][c]=ans;
            	return ans;
            }
            int main(){
            	LL a,b,c;
            	while(cin>>a>>b>>c){
            	if(a==-1&&b==-1&&c==-1)
            		return 0;
            	printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,w(a,b,c));
            	}
            return 0;
            }
            
            
            • -2
              @ 2022-4-17 15:07:06
              #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 num [30][30][30];
              LL w(int a , int b , int c){
              	if(a<=0||b<=0||c<=0)
              		return 1; 
              	if(a>20||b>20||c>20)
              		return w(20,20,20);
              	if(num [a][b][c])
              		return num [a][b][c];
              	LL ans=0;
              	if(a<b&&b<c)
              		ans= w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
              	else
              		ans= w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
              	num [a][b][c]=ans;
              	return ans;
              }
              int main(){
              	LL a,b,c;
              	while(cin>>a>>b>>c){
              	if(a==-1&&b==-1&&c==-1)
              		return 0;
              	printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,w(a,b,c));
              	}
              return 0;
              }
              
              • -4
                @ 2021-12-4 18:47:29
                #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 num [30][30][30];
                LL w(int a , int b , int c){
                	if(a<=0||b<=0||c<=0)
                		return 1; 
                	if(a>20||b>20||c>20)
                		return w(20,20,20);
                	if(num [a][b][c])
                		return num [a][b][c];
                	LL ans=0;
                	if(a<b&&b<c)
                		ans= w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
                	else
                		ans= w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
                	num [a][b][c]=ans;
                	return ans;
                }
                int main(){
                	LL a,b,c;
                	while(cin>>a>>b>>c){
                	if(a==-1&&b==-1&&c==-1)
                		return 0;
                	printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,w(a,b,c));
                	}
                return 0;
                }
                
                • @ 2022-4-6 21:08:10

                  没问题的一个题解

                • @ 2023-5-1 16:43:42

                  确实没问题

              • 1

              信息

              ID
              1230
              时间
              1000ms
              内存
              128MiB
              难度
              7
              标签
              递交数
              741
              已通过
              154
              上传者