The above-mentioned problem of the four KC classification range of the solution can be directly in the Ronfain "a kind of guessing the problem of the study" find · For the copyright issue, I'm not going to post it here ...
Code:
#include <iostream>#include<cstdio>#include<cstdlib>#include<cmath>#include<ctime>#include<cctype>#include<string>#include<cstring>#include<algorithm>using namespaceStd;inlineLong LongR () {CharCLong Longf=0; for(C=getchar ();c<'0'|| C>'9'; c=GetChar ()); for(; c<='9'&&c>='0'; C=getchar ()) f=f*Ten+c-'0'; returnF;}intT;Long Longn,k,c;Long Longf1=0, f2[80000][ the],f3[505],f4[70000][ the];intMain () {T=R (); while(t--) {n=r (), K=r (), c=R (); if(n==k&&c==0) {F1=0;inttim=0; while(f1<N) {F1=2*f1+1; Tim++; } cout<<tim<<"\ n"; } Else if(c==0){ BOOLflag=false; for(intI=1;; i++){ if(flag) Break; for(intj=1; j<=k;j++) {F2[i][j]=f2[i-1][j-1]+f2[i-1][j]+1; if(f2[i][j]>=N) {cout<<i<<"\ n"; flag=true; Break; } } } } Else if(n==k&&c!=0){ for(intI=2;; i++) {F3[i]=f3[i-1]+f3[i-2]+1; if(f3[i]>=N) {cout<<i<<"\ n"; Break; } } } Else{ BOOLflag=false; for(intI=2;; i++){ if(flag) Break; for(intj=1; j<=k;j++){ if(j>1) F4[i][j]=max (f4[i-1][j-1]+f4[i-2][j],f4[i-2][j-2]+f4[i-1][J]) +1; ElseF4[i][j]=max (f4[i-1][j-1]+f4[i-2][j],f4[i-1][J]) +1; if(f4[i][j]>=N) {cout<<i<<Endl; Flag=true; Break; } } } } } return 0;}
Algorithm review--guessing number problem