4 条题解

  • 1
    @ 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;
      }
      
      
      • 0
        @ 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;
        }
        
        • -2
          @ 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;
          }
          
        • 1

        信息

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