結果

問題 No.423 ハムスター語初級(数詞)
ユーザー Yug_min_nullYug_min_null
提出日時 2021-09-14 00:11:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 866 bytes
コンパイル時間 1,875 ms
コンパイル使用メモリ 189,412 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 08:42:31
合計ジャッジ時間 2,511 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#define ll long long
#include <bits/stdc++.h>
using namespace std;

int main() {
  string S; cin >> S;
  string T = "";
  if(S == "ham"){
    cout << S << endl;
    return 0;
  }
  while((int)S.size() != 0){
    if((int)S.size() == 3){
      T += "0";
      S = "";
    }else{
      if(S.substr(0, 4) == "hamu"){
        T += "1";
        string U = S.substr(4, (int)S.size());
        S = U;
      }else{
        T += "0";
        string U = S.substr(3, (int)S.size());
        S = U;
      }
    }
  }
  int X = 0;
  reverse(T.begin(), T.end());
  for(int i = 0; i < (int)T.size(); i++){
    if(T[i] == '1'){
      int U = (int)pow(2, i);
      X += U;
    }
  }
  X *= 2;
  string ans = "";
  while(X != 0){
    if(X%2 == 0) ans += "mah";
    else ans += "umah";
    X /= 2;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

0