Portal Password: waxadyt
T1
Hit the table to find the law
Starting from n> = 5, the difference between two adjacent numbers there is a tolerance of 28 arithmetic sequence
Directly to the bar code
#include<bits/stdc++.h> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { unsigned long long n; cin>>n; if(n==0){printf("1\n");continue;} if(n==1){printf("9\n");continue;} if(n==2){printf("41\n");continue;} if(n==3){printf("109\n");continue;} if(n==4){printf("205\n");continue;} if(n==5){printf("325\n");continue;} cout<<325+(148+(n-6)*14)*(n-5); } }
T2
dfs bare title
Plus a vis
Code
#include<bits/stdc++.h> using namespace std; int vis[(1<<11)+1]; int a[1001001],n,p; void dfs(int pos) { if(p)return; if(pos==(1<<n)+1-n) { for(int i=1;i<=(1<<n);i++) { printf("%d",a[i]); } p= 1 ; return ; } Int num = 0 ; for ( int i = pos-m + 1 ; i <= pos; i ++) whether = (whether << 1 ) + a [i]; if (! force [whether]) { from [pos] = 0 ; force [num] = 1 ; DFS (pos + 1 ); force [num] = 0 ; } If (b) return ; force [num + 1 ] =1; a[pos]=1;dfs(pos+1); } int main() { scanf("%d",&n); for(int i=(1<<n)-n+1;i<=1<<n;i++)a[i]=1; vis[0]=1; int num=(1<<n)-1; for(int i=0;i<n;i++) { vis[num]=1; num^=(1<<i); } printf("%d ",1<<n); dfs(n+1); }
T3
Leave a pit