結果

問題 No.423 ハムスター語初級(数詞)
ユーザー ldsybldsyb
提出日時 2016-09-22 22:49:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 451 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 68,752 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 19:49:50
合計ジャッジ時間 1,262 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	string n ,s = "", ans = "";
	cin >> n;
	for(int i = 0; i < n.size() - 3; i += 3){
		s += n[i + 3] == 'u' ? '1' : '0';
		if(n[i + 3] == 'u') i++;
	}
	int num = 2 * stoi(s, nullptr, 2);
	s = "";
	while(num){
		s += num & 1 ? '1' : '0';
		num >>= 1;
	}
	reverse(s.begin(), s.end());
	for(int i = 0; i < s.size(); i++) ans += s[i] == '1' ? "hamu" : "ham";
	cout << ans << endl;
}
0