Original title: m Xiaoming the coins on a line segment n endpoints define a "Operations": at least two from a point removed coins 2 coins, were placed on each of the adjacent points 1 pieces (if only a point adjacent to only put a point on a neighboring). Xiaoming of each pendulum method, the n-th point a n no coin, then the total number after several "operations", so that point a n the coin, for the minimum of n.
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int inline gin(){ 5 char c=getchar(); 6 int s=0; 7 while(c<'0'||c>'9'){ 8 c=getchar(); 9 } 10 while(c>='0'&&c<='9'){ 11 s=(s<<3)+(s<<1)+(c^48); 12 c=getchar(); 13 } 14 return s; 15 } 16 17 int n,a[10001],k=0; 18 19 int tf(int s){ 20 memset(a,0,sizeof(a)); 21 a[1]=s; 22 for(int i=1;i<n;i++){ 23 while(a[i]>=2){ 24 a[i+1]+=a[i]/2; 25 a[i]=a[i]%2+(a[i]/2)/2; 26 } 27 } 28 if(a[n])return 1; 29 return 0; 30 } 31 32 int main(){ 33 for(n=1;n<=20;n++){ 34 for(int i=pow(2,n-1)-1;;i--){ 35 if(!tf(i)){ 36 k=i+1; 37 break; 38 } 39 } 40 cout<<n<<" "<<k<<endl; 41 } 42 return 0; 43 }n m
1 1 2 2 3 4 4 7 5 12 6 19 7 29 8 45 9 68 10 104 11 157 12 237 13 357 14 537 15 808 16 1213 17 1821 18 2735 19 4104 20 6157 21 9237 22 13858 23 20788 24 31184
Output