#include #include #include using namespace std; typedef long long ll; int N; int ans[10010][2] = {{0}}; ll resB[10010] = {0},resF[10010] = {0},resS[10010] = {0}; ll fac_num[6] = {0},fac_level[6] = {0},beki[20] = {1}; ll fac_price[6] = {0,150,2000,3000,60000,10000000};//逐次更新する ll fac_reinforce_price[6] = {15,1500,20000,30000,600000,100000000};//逐次更新する ll fac_gain[6] = {1,1,10,120,2000,25000}; string fac_name[6] = {"click","hand","lily","factory","casino","grimoire"}; string S,result; void print(){ for(int i=1;i<=N;i++){ if(ans[i][0]==1) cout << "click" << endl; if(ans[i][0]==2) cout << "buy " << fac_name[ans[i][1]] << endl; if(ans[i][0]==3) cout << "sell " << fac_name[ans[i][1]] << endl; if(ans[i][0]==4) cout << "reinforce " << fac_name[ans[i][1]] << endl; if(ans[i][0]==5) cout << "enhclick" << endl; if(ans[i][0]==6) cout << "nothing" << endl; cin >> result; } } ll gain_from_fac(){ ll gain = 0; for(int i=1;i<=5;i++) gain += beki[fac_level[i]]*fac_num[i]*fac_gain[i]; return gain; } void reinforce_fac(int n){ fac_level[n]++; fac_reinforce_price[n] *= 10; } void buy_fac(int n){ fac_num[n]++; fac_price[n] = fac_price[n]*6/5; } ll is_purchase_good(int n,int time){ return beki[fac_level[n]]*(N-time+1+(resF[time]*7))+resB[time]*(beki[fac_level[n]]+99)/100 - fac_price[n]; } int main(){ cin >> N >> S; fac_num[0] = 1; for(int i=1;i<=20;i++) beki[i] = 2*beki[i-1]; for(int i=N;i>=1;i--){ resB[i] = (S[i]=='B'); resB[i] += resB[i-1]; resF[i] = (S[i]=='F'); resF[i] += resF[i-1]; resS[i] = (S[i]=='S'); resS[i] += resS[i-1]; } ll money = 0; for(int i=1;i<=N;i++){ int f = 0; ll ma = 0,gain = 0,loss = 0; for(int j=1;j<=5;j++){ if(fac_price[j]>money || 10<=(int) fac_num[j]) continue; if(mamoney || f==0){ gain++; ans[i][0] = 1; } else{ loss = fac_price[f]; buy_fac(f); ans[i][0] = 2; ans[i][1] = f; } gain += gain_from_fac(); if(S[i-1]=='F') gain *= 7; if(S[i-1]=='S'){loss *= 9; loss = (loss+9)/10;} money += gain-loss; if(S[i-1]=='B') money += (money+99)/100; //assert(money>=0); } /*for(int i=1;i<=N;i++){ cout << ans[i][0] << " " << ans[i][1] << endl; }*/ for(int i=1;i<=5;i++){ cerr << fac_num[i] << endl; } cerr << money << endl; print(); }