1 条题解

  • -1
    @ 2024-1-28 17:48:55

    究极暴力,九重循环

    #include<bits/stdc++.h>
    #define up(i) for(int i=0;i<=3;i++)
    using namespace std;
    int a[10],t[10];
    int check(int a[]){
    	for(int i=1;i<=9;i++){
    		if(a[i]%12)return 0;
    	}
    	return 1;
    }
    int main(){
    	ios::sync_with_stdio(false);
    	cin.tie(0),cout.tie(0);
    	for(int i=1;i<=9;i++){
    		cin>>a[i];
    	}
    	up(i){
    		up(j){
    			up(k){
    				up(o){
    					up(p){
    						up(q){
    							up(x){
    								up(y){
    									up(z){
    										t[1]=a[1]+(i+j+o)*3;
    										t[2]=a[2]+(i+j+k+p)*3;
    										t[3]=a[3]+(j+k+q)*3;
    										t[4]=a[4]+(i+o+p+x)*3;
    										t[5]=a[5]+(i+k+p+x+z)*3;
    										t[6]=a[6]+(k+p+q+z)*3;
    										t[7]=a[7]+(o+x+y)*3;
    										t[8]=a[8]+(p+x+y+z)*3;
    										t[9]=a[9]+(q+y+z)*3;
    										if(check(t)){
    											while(i--)cout<<1<<" ";
    											while(j--)cout<<2<<" ";
    											while(k--)cout<<3<<" ";
    											while(o--)cout<<4<<" ";
    											while(p--)cout<<5<<" ";
    											while(q--)cout<<6<<" ";
    											while(x--)cout<<7<<" ";
    											while(y--)cout<<8<<" ";
    											while(z--)cout<<9<<" ";
    											return 0;
    										}
    									}
    								}
    							}
    						}
    					}
    				}
    			}
    		}
    	}
    	return 0;
    }
    
    • 1

    信息

    ID
    234
    时间
    1000ms
    内存
    64MiB
    难度
    4
    标签
    递交数
    11
    已通过
    8
    上传者