#include #include #include #include #include #include #include #include using namespace std; using ll = long long; #define CIN( LL , A ) LL A; cin >> A #define GETLINE( A ) string A; getline( cin , A ) #define GETLINE_SEPARATE( A , SEPARATOR ) string A; getline( cin , A , SEPARATOR ) #define FOR_LL( VAR , INITIAL , FINAL_PLUS_ONE ) for( ll VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define FOR_ITR( ARRAY , ITR , END ) for( auto ITR = ARRAY .begin() , END = ARRAY .end() ; ITR != END ; ITR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR_LL( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) #define RETURN( ANSWER ) cout << ( ANSWER ) << endl; return 0 #define DOUBLE( PRECISION , ANSWER ) cout << fixed << setprecision( PRECISION ) << ( ANSWER ) << endl; return 0 #define MIN( A , B ) A < B ? A : B; #define MAX( A , B ) A < B ? B : A; int main() { CIN( ll , N ); CIN( string , S ); ll cookie = 200; ll price[7] = { 0 , 150 , 2000 , 30000 , 600000 , 1000000 , 0 }; ll price_last[7] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 }; ll enh[7] = { 15 , 1500 , 20000 , 300000 , 6000000 , 10000000 , 0 }; ll num[7] = { 1 , 0 , 0 , 0 , 0 , 0 , 0 }; ll click[7] = { 1 , 1 , 10 , 120 , 2000 , 25000 , -1 }; string name[7] = { "hand" , "lily" , "factory" , "casino" , "grimoire" }; string effect[3] = { "B" , "F" , "S" }; ll status = 0; ll fever = -1; ll sale = -1; string reply; FOR_LL( t , 0 , N ){ ll price_next = sale == -1 ? price[status + 1] : ( price[status + 1] * 9 ) / 10 + ( price[status + 1] % 10 == 0 ? 0 : 1 ); ll price_current = sale == -1 ? price[status] : ( price[status] * 9 ) / 10 + ( price[status] % 10 == 0 ? 0 : 1 ); ll sell_current = price_last[status] / 4 + ( price_last[status] % 4 == 0 ? 0 : 1 ); ll enh_current = sale == -1 ? enh[status] : ( enh[status] * 9 ) / 10 + ( enh[status] % 10 == 0 ? 0 : 1 ); ll rate = fever == -1 ? 1 : 7; // 特殊効果を考慮せず2ターン分の行動しか評価しない決め打ち if( cookie > price_next && price_next < ( N - t ) * click[status + 1] ){ status++; cookie -= price_next; price_last[status] = price_next; price[status] = ( price[status] * 6 ) / 5 + ( ( price[status] * 6 ) % 5 == 0 ? 0 : 1 ); num[status]++; cout << "buy " + name[status] << endl << flush; } else if( cookie + sell_current > price_next && num[status] > 0 && price_next < ( N - t ) * click[status + 1] ){ cookie += sell_current; num[status]--; cout << "sell " + name[status] << endl << flush; } else if( cookie > enh_current && enh_current < ( N - t ) * click[status] ){ cookie -= enh_current; enh[status] = enh[status] * 10; click[status] *= 2; cout << ( status == 0 ? "enhclick " : "reinforce " + name[status] ) << endl << flush; } else if( cookie > price_current && price_current < ( N - t ) * click[status] && status > 0 ){ cookie -= price_current; price[status] = ( price[status] * 6 ) / 5 + ( ( price[status] * 6 ) % 5 == 0 ? 0 : 1 ); num[status]++; cout << "buy " + name[status] << endl << flush; } else { cookie += click[0] * rate; cout << "click" << endl << flush; } cin >> reply; FOR_LL( j , 1 , 7 ){ cookie += click[j] * num[j] * rate; } if( fever != -1 ){ if( fever < 19 ){ fever++; } else { fever = -1; } } sale = -1; string Si = S.substr( t , 1 ); if( Si == effect[0] ){ cookie += cookie / 100 + ( cookie % 100 == 0 ? 0 : 1 ); } else if( Si == effect[1] ){ fever = 0; } else if( Si == effect[2] ){ sale = 0; } } return 0; }