結果

問題 No.423 ハムスター語初級(数詞)
ユーザー aaaaaa
提出日時 2018-10-29 20:25:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,294 bytes
コンパイル時間 823 ms
コンパイル使用メモリ 94,096 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-12 08:47:01
合計ジャッジ時間 1,466 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 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;

	if (s == "ham") {
		cout << "ham" << endl;
	}


	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<50>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