2 solutions

  • 1
    @ 2024-1-28 11:11:37
    #include <bits/stdc++.h>
    //仅供参考
    using namespace std;
    
    int back(int a[],int that,int k){
    	if(a[that] == 0){
    		return k;
    	}else{
    		int space = (that+1) * (that+1);
    		a[that]--;
    		short q = 1;
    		short q1 = 0;
    		while(space < 36){
    			bool has = false;
    			for(int i = 4-that;i>=0;i--){
    				if(a[i] >= 1 and 36 - space >= (i+1)*(i+1)){
    					if(i == 2){
    						q++;
    					}
    					if(that == 2 and i == 1 and q1 >= 7 - (2 * q)){
    						continue;
    					}else if(i == 1){
    						q1++;
    					}
    					a[i]--;
    					space += (i+1)*(i+1);
    					has = true;
    					break;
    				}
    			}
    			if(has == false){
    				break;
    			}
    		}
    		return back(a,that,k+1);
    	}
    }
    
    int main(){
    	int a[6] = {0};
    	bool b = true;
    	while(b){
    		b = false;
    		int k = 0;
    		for(int i = 0;i < 6;i++){
    			cin >> a[i];
    		}
    		for(int i = 0;i < 6;i++){
    			if(a[i] != 0){
    				b = true;
    				break;
    			}
    		}
    		if(b == false){
    			break;
    		}
    		for(int j = 5;j >= 0;j--){
    			k += back(a,j,0);
    		}
    		cout << k << endl;
    	}
    	return 0;
    }
    
    • 0
      @ 2024-5-23 14:18:35
      #include <bits/stdc++.h>
      //仅供参考
      using namespace std;
      
      int back(int a[],int that,int k){
      	if(a[that] == 0){
      		return k;
      	}else{
      		int space = (that+1) * (that+1);
      		a[that]--;
      		short q = 1;
      		short q1 = 0;
      		while(space < 36){
      			bool has = false;
      			for(int i = 4-that;i>=0;i--){
      				if(a[i] >= 1 and 36 - space >= (i+1)*(i+1)){
      					if(i == 2){
      						q++;
      					}
      					if(that == 2 and i == 1 and q1 >= 7 - (2 * q)){
      						continue;
      					}else if(i == 1){
      						q1++;
      					}
      					a[i]--;
      					space += (i+1)*(i+1);
      					has = true;
      					break;
      				}
      			}
      			if(has == false){
      				break;
      			}
      		}
      		return back(a,that,k+1);
      	}
      }
      
      int main(){
      	int a[6] = {0};
      	bool b = true;
      	while(b){
      		b = false;
      		int k = 0;
      		for(int i = 0;i < 6;i++){
      			cin >> a[i];
      		}
      		for(int i = 0;i < 6;i++){
      			if(a[i] != 0){
      				b = true;
      				break;
      			}
      		}
      		if(b == false){
      			break;
      		}
      		for(int j = 5;j >= 0;j--){
      			k += back(a,j,0);
      		}
      		cout << k << endl;
      	}
      	return 0;
      }
      
      
      • 1

      Information

      ID
      711
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      7
      Tags
      # Submissions
      60
      Accepted
      13
      Uploaded By