某蒟蒻成功的·写出了T1并rank16。。。小岛的题目真难。。。
传送门:http://hihocoder.com/contest/challenge26
T1
如果你想要暴力枚举的话显然是不行的
如果你想要打表找规律的话显然也是不行的
可以(很容易地)想到逆推法
因为每一个n都是由某两个数结合而成
所以只要随机两个数并检验就可以了
细节就不明说了。
Code:
1 #include <ctime> 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 #define Rand(x) ((rand()%10000*10000+rand()%10000)%x) 7 using namespace std; 8 9 int rec[65],T,n; 10 11 int doit() 12 { 13 bool flag=1;int now=0;memset(rec,0,sizeof rec); 14 while (flag) 15 { 16 int A=Rand(n),B=n-A;now=0; 17 while (A==0) A=Rand(n),B=n-A; 18 while (!(A==1 && B==1)) 19 { 20 if (A==B) break; 21 if (A>B) A-=B,rec[++now]=0; 22 else B-=A,rec[++now]=1; 23 if (now>55) break; 24 } 25 if (A==1 && B==1) flag=0; 26 if (flag) memset(rec,0,sizeof rec),now=0; 27 if (now>=60) flag=0; 28 } 29 for (int i=now+1;i>=0;i--) cout<<rec[i]; 30 cout<<endl; 31 } 32 33 void File() 34 { 35 freopen("1.in","r",stdin); 36 freopen("1.out","w",stdout); 37 } 38 39 int main() 40 { 41 srand(time(0)); 42 cin>>T; 43 while (T--) 44 { 45 cin>>n; 46 if (n==2) cout<<"00"<<endl; 47 else if (n==3) cout<<"000"<<endl; 48 else if (n==4) cout<<"0000"<<endl; 49 else doit(); 50 } 51 }
T2T3T4的话就贴个题解好了
code的话以后再更
传送门:https://media.hihocoder.com/contests/challenge26/solution.pdf
毕竟本蒟蒻实在是太弱了