#include #define long long long char const* fnames[]={"hand","lily","factory","casino","grimoire"}; bspeeds[]={1,10,120,2000,25000}; bprices[]={150,2000,30000,600000,10000000}; char const*action="AABBBBBBCBBDDBDBDADBDEDDFFFDFDCBBBFBFGFFHHBHBDHHHBBIHBJJJBEBBJJJCBBBBBKBBAGI"; char buf[20000]; long buy_price(long base,int num){ long price=base; for(;num--;){ price=(price*6+4)/5; } return price; } long rein_price(long base,int lvl){ long price=base; for(;lvl--;){ price*=10; } return price; } main(){ gets(buf); gets(buf); long cookie=0; int cl=0; int n[5]={0,0,0,0,0}; int l[5]={0,0,0,0,0}; for(int turn=0;turn<10000;++turn){ // action int done=0; int a=*action; if(a=='A'){ // enhclick int price=rein_price(15,cl); if(cookie>=price){ cookie-=price; cl+=1; done=1; puts("enhclick"); } }else if(a>='B'&&a<='K'){ int i=a-'B'>>1; if(a&1){ // reinforce int price=rein_price(bprices[i]*10,l[i]); if(cookie>=price){ cookie-=price; l[i]+=1; done=1; printf("reinforce %s\n",fnames[i]); } }else{ // buy int price=buy_price(bprices[i],n[i]); if(cookie>=price){ cookie-=price; n[i]+=1; done=1; printf("buy %s\n",fnames[i]); } } } if(done){ ++action; }else{ // click cookie+=1<