1 条题解

  • 0
    @ 2023-11-15 15:15:05
    #include<bits/stdc++.h>
    using namespace std;
    int n,sum,box[15],c[15];
    int sh(int h){
    	for(int i=2;i<=h-1;i++){
    		if(h==2){
    			return 1;
    		}
    		if(){
    			return 0;
    		}
    	}
    	return 1;
    }
    void s(int st){
    	if(st==n+1){
    		sum++;
    		return;
    	}
    	for(int i=1;i<=n;i++){
    		if(st==1){
    			c[1]=i;
    			box[i]=1;
    			s(st+1);
    			box[i]=0;
    		}
    		else{
    			if(box[i]==0){
    				c[st]=i;
    				if(sh(c[st]+c[st-1])==1){
    					box[i]=1;
    			        s(st+1);
    			        box[i]=0;
    				}
    			}
    		}
    	}
    	return;
    }
    int main(){
    	cin>>n;
    	s(1);
    	cout<<sum;
    	return 0;
    }
    
    • 1

    信息

    ID
    1306
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    递交数
    150
    已通过
    24
    上传者