#include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; //クッキーの量と1ターンあたりの生産量(クリック含まず、含む) ll cooky = 0; ll pro = 1; ll clipro = 1; //現在の施設価格 ll click = 15; ll hand = 150; ll lily = 2000; ll factory = 30000; ll casino = 600000; ll grimoire = 10000000; //強化にかかるお金 ll rfgri = 100000000; ll enhcli = 15; ll rfhan = 1500; ll rflil = 20000; ll rffac = 300000; ll rfcas = 6000000; //強化回数 ll enhclitime = 0; ll rfgritime = 0; ll rfhantime = 0; ll rfliltime = 0; ll rffactime = 0; ll rfcastime = 0; //各施設の数(強化した場合は2倍になる) ll gritime = 0; ll hantime = 0; ll liltime = 0; ll factime = 0; ll castime = 0; //各操作の効率 ll hanm; ll lilm; ll facm; ll casm; ll grim; ll rfgrim; ll enhclim; ll rfhanm; ll rflilm; ll rffacm; ll rfcasm; //目標金額 ll amemoney; //目標金額上限 ll amemax = 500000000000; //目標金額下限 ll amemin = 0; //パラメータ ll para = 1; int minn(ll a, ll b, ll c, ll d, ll e, ll f, ll g, ll h, ll i, ll j, ll k){ ll minx = 1000000000000; int mark = -1; ll risu[11] = {a,b,c,d,e,f,g,h,i,j,k}; for(int i = 0; i < 11; i++){ if(risu[i] < minx){ minx = risu[i]; mark = i; } } return mark; } int main(){ int n; char s[10000]; scanf("%d%s", &n, s); for(int i = 0; i < n; i++){ if(s[i] == 'F'){ s[i] = 'N'; for(int j = 0; j < 20; j++){ if(i+j+1 == n){ i = n-21; break; } s[i+1+j] = 'F'; } i += 20; } if(s[i] == 'S'){ s[i] = 'N'; if(i+1 == n){ break; } s[i+1] = 'S'; i++; } } int comand[10000]; int turn; while(1){ if(amemax == amemin || amemax-1 == amemin){ break; } amemoney = (amemax+amemin)/2; //クッキーの量と1ターンあたりの生産量(クリック含まず、含む) cooky = 0; pro = 1; clipro = 1; //現在の施設価格 click = 15; hand = 150; lily = 2000; factory = 30000; casino = 600000; grimoire = 10000000; //強化にかかるお金 rfgri = 100000000; enhcli = 15; rfhan = 1500; rflil = 20000; rffac = 300000; rfcas = 6000000; //強化回数 enhclitime = 0; rfgritime = 0; rfhantime = 0; rfliltime = 0; rffactime = 0; rfcastime = 0; //各施設の数(強化した場合は2倍になる) gritime = 0; hantime = 0; liltime = 0; factime = 0; castime = 0; //パラメータ para = 1; //ターン turn = 0; while(1){ //各操作の効率 かかるターン数をデメリットとして加算してもいいかも hanm = hand/(1*pow(2,rfhantime)); lilm = lily/(10*pow(2,rfliltime)); facm = factory/(120*pow(2,rffactime)); casm = casino/(2000*pow(2,rfcastime)); grim = grimoire/(25000*pow(2,rfgritime)); rfgrim = rfgri/(25000*gritime); enhclim = enhcli/(1*pow(2,enhclitime)); rfhanm = rfhan/(1*hantime); rflilm = rflil/(10*liltime); rffacm = rffac/(120*factime); rfcasm = rfcas/(2000*castime); int opt = minn(hanm, lilm, facm, casm, grim, rfgrim, enhclim, rfhanm, rflilm, rffacm, rfcasm); //optの値で場合分け if(opt == 0){ //handを買う場合 if((hand-cooky)/clipro+amemoney/(clipro+1*pow(2,rfhantime)) <= (amemoney-cooky)/clipro){ //ずっとクリック while(cooky < hand){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //hand購入 comand[turn] = 1; //セール時の購入 if(s[turn] == 'S'){ cooky -= (hand*9+9)/10; } //非セール時の購入 else{ cooky -= hand; } //更新 hand = (hand*6+4)/5; clipro += 1*pow(2,rfhantime); pro += 1*pow(2,rfhantime); if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; hantime += pow(2,rfhantime); continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 1){ //lilyを買う場合 if((lily-cooky)/clipro+amemoney/(clipro+10*pow(2,rfliltime)) < (amemoney-cooky)/clipro){ //ずっとクリック while(cooky < lily){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //lily購入 comand[turn] = 2; //セール時の購入 if(s[turn] == 'S'){ cooky -= (lily*9+9)/10; } //非セール時の購入 else{ cooky -= lily; } //更新 lily = (lily*6+4)/5; clipro += 10*pow(2,rfliltime); pro += 10*pow(2,rfliltime); if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; liltime += pow(2,rfliltime); continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 2){ //factoryを買う場合 if((factory-cooky)/clipro+amemoney/(clipro+120*pow(2,rffactime)) < (amemoney-cooky)/clipro){ //ずっとクリック while(cooky < factory){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //factory購入 comand[turn] = 3; //セール時の購入 if(s[turn] == 'S'){ cooky -= (factory*9+9)/10; } //非セール時の購入 else{ cooky -= factory; } //更新 factory = (factory*6+4)/5; clipro += 120*pow(2,rffactime); pro += 120*pow(2,rffactime); if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; factime += pow(2,rffactime); continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 3){ //casinoを買う場合 if((casino-cooky)/clipro+amemoney/(clipro+2000*pow(2,rfcastime)) < (amemoney-cooky)/clipro){ //ずっとクリック while(cooky < casino){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //casino購入 comand[turn] = 4; //セール時の購入 if(s[turn] == 'S'){ cooky -= (casino*9+9)/10; } //非セール時の購入 else{ cooky -= casino; } //更新 casino = (casino*6+4)/5; clipro += 2000*pow(2,rfcastime); pro += 2000*pow(2,rfcastime); if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; castime += pow(2,rfcastime); continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 4){ //grimoireを買う場合 if((grimoire-cooky)/clipro+amemoney/(clipro+25000*pow(2,rfgritime)) < (amemoney-cooky)/clipro){ //ずっとクリック while(cooky < grimoire){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //grimoire購入 comand[turn] = 5; //セール時の購入 if(s[turn] == 'S'){ cooky -= (grimoire*9+9)/10; } //非セール時の購入 else{ cooky -= grimoire; } //更新 grimoire = (grimoire*6+4)/5; clipro += 25000*pow(2,rfgritime); pro += 1*pow(2,rfgritime); if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; gritime += pow(2,rfgritime); continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 5){ //grimoireを強化する場合 if((rfgri-cooky)/clipro+amemoney/(clipro+25000*gritime) < (amemoney-cooky)/clipro){ while(cooky < rfgri){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //grimoire強化 comand[turn] = 16; //セール時の購入 if(s[turn] == 'S'){ cooky -= (rfgri*9+9)/10; } //非セール時の購入 else{ cooky -= rfgri; } //更新 rfgri = rfgri*10; rfgritime++; clipro += gritime*25000; pro += gritime*25000; gritime *= 2; if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 6){ //grimoireを強化する場合 if((enhcli-cooky)/clipro+amemoney/(clipro+1*pow(2,enhclitime)) < (amemoney-cooky)/clipro){ while(cooky < enhcli){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //click強化 comand[turn] = 11; //セール時の購入 if(s[turn] == 'S'){ cooky -= (enhcli*9+9)/10; } //非セール時の購入 else{ cooky -= enhcli; } //更新 enhcli = enhcli*10; enhclitime++; clipro += 1*pow(2,enhclitime); pro += 1*pow(2,enhclitime); if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 7){ //handを強化する場合 if((rfhan-cooky)/clipro+amemoney/(clipro+1*hantime) < (amemoney-cooky)/clipro){ while(cooky < rfhan){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //hand強化 comand[turn] = 12; //セール時の購入 if(s[turn] == 'S'){ cooky -= (rfhan*9+9)/10; } //非セール時の購入 else{ cooky -= rfhan; } //更新 rfhan = rfhan*10; rfhantime++; clipro += hantime*1; pro += hantime*1; hantime *= 2; if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 8){ //lilyを強化する場合 if((rflil-cooky)/clipro+amemoney/(clipro+10*liltime) < (amemoney-cooky)/clipro){ while(cooky < rflil){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //lily強化 comand[turn] = 13; //セール時の購入 if(s[turn] == 'S'){ cooky -= (rflil*9+9)/10; } //非セール時の購入 else{ cooky -= rflil; } //更新 rflil = rflil*10; rfliltime++; clipro += liltime*10; pro += liltime*10; liltime *= 2; if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 9){ //factoryを強化する場合 if((rffac-cooky)/clipro+amemoney/(clipro+120*factime) < (amemoney-cooky)/clipro){ while(cooky < rffac){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //factory強化 comand[turn] = 14; //セール時の購入 if(s[turn] == 'S'){ cooky -= (rffac*9+9)/10; } //非セール時の購入 else{ cooky -= rffac; } //更新 rffac = rffac*10; rffactime++; clipro += 120*factime; pro += 120*factime; factime *= 2; if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } if(opt == 10){ //casinoを強化する場合 if((rfcas-cooky)/clipro+amemoney/(clipro+2000*castime) < (amemoney-cooky)/clipro){ while(cooky < rfcas){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n-1) break; } if(turn==n-1 || turn==n-2){ amemax = amemoney; break; } //casino強化 comand[turn] = 15; //セール時の購入 if(s[turn] == 'S'){ cooky -= (rfcas*9+9)/10; } //非セール時の購入 else{ cooky -= rfcas; } //更新 rfcas = rfcas*10; rfcastime++; clipro += 2000*castime; pro += 2000*castime; castime *= 2; if(s[turn] == 'F'){ cooky += 7*pro; } else{ cooky += pro; } if(s[turn] == 'B'){ cooky = cooky + (cooky+99)/100; } turn++; continue; } else{ //ずっとクリック while(cooky < amemoney){ comand[turn] = 0; //フィーバー時の生産 if(s[turn] == 'F'){ cooky += 7*clipro; } //フィーバーしてないときの生産 else{ cooky += clipro; } //ボーナスターンの追加クッキー if(s[turn] == 'B'){ cooky = (cooky+99)/100 + cooky; } turn++; if(turn==n) break; } if(turn == n && cooky < amemoney){ amemax = amemoney; break; } amemin = amemoney; break; } } } } for(int i = 0; i < n; i++){ //コマンド列 if(comand[i]==-1){ printf("nothing\n"); } if(comand[i]==0){ printf("click\n"); } if(comand[i]==1){ printf("buy hand\n"); } if(comand[i]==2){ printf("buy lily\n"); } if(comand[i]==3){ printf("buy factory\n"); } if(comand[i]==4){ printf("buy casino\n"); } if(comand[i]==5){ printf("buy grimoire\n"); } if(comand[i]==6){ printf("sell hand\n"); } if(comand[i]==7){ printf("sell lily\n"); } if(comand[i]==8){ printf("sell factory\n"); } if(comand[i]==9){ printf("sell casino\n"); } if(comand[i]==10){ printf("sell grimoire\n"); } if(comand[i]==11){ printf("enhclick\n"); } if(comand[i]==12){ printf("reinforce hand\n"); } if(comand[i]==13){ printf("reinforce lily\n"); } if(comand[i]==14){ printf("reinforce factory\n"); } if(comand[i]==15){ printf("reinforce casino\n"); } if(comand[i]==16){ printf("reinforce grimoire\n"); } fflush(stdout); scanf("%s", s); } //cout << cooky << endl; return 0; }