結果

問題 No.423 ハムスター語初級(数詞)
ユーザー aaaaaa
提出日時 2018-10-29 20:18:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,246 bytes
コンパイル時間 911 ms
コンパイル使用メモリ 95,796 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 23:13:09
合計ジャッジ時間 1,450 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>

using namespace std;

int main(){
	int i, j;
	string s;

	cin >> s;

	string s1;


	while (true)
	{

		for (i = 0; i < 3; i++) {
			s.erase(s.begin());
		}

		if (s.length() <= 0) {
			s1 += '0';
			break;
		}
		
		if (s[0] == 'u') {
			s1 += '1';
			s.erase(s.begin());
		}
		else {
			s1 += '0';
		}

		if (s.length() <= 0) {
			break;
		}
	}
	
	int num = 0, kis = 1;

	for (i = s1.length() - 1; i >= 0; i--) {
		num += ((int)s1[i] - 48) * kis;
		kis *= 2;
	}

	num *= 2;

	bitset<40>bb(num);

	string s2 = bb.to_string();

	//cout << "num->" << num << endl;
	//cout << "s2->" << s2 << endl;


	int len = s2.length();

	for (i = 0; i < len; i++) {
		if (s2[0] == '0') {
			s2.erase(s2.begin());
		}
		else {
			break;
		}
	}

	string s3;

	for (i = 0; i < s2.length(); i++) {
		if (s2[i] == '1') {
			s3 += "hamu";
		}
		else {
			s3 += "ham";
		}
	}

	cout << s3 << endl;




	getchar();
	getchar();
	return 0;
}
0