結果

問題 No.423 ハムスター語初級(数詞)
ユーザー kapokapo
提出日時 2016-09-22 22:49:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,683 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 79,832 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 02:44:40
合計ジャッジ時間 1,151 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;
#define debug2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define debugv(v) for(auto&& x : v){cout << x << " ";} cout << endl

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll; 

int main()
{
	string s;
	cin >> s;
	Vi v;
	while (1) {
		if (len(s) > 3 && s[3] == 'u') {
			v.pb(1);
			s = s.substr(4);
		}
		else {
			v.pb(0);
			s = s.substr(3);
		}
		if (len(s)<3) break;
	}

	int sum = 0, k = 1;
	reverse(all(v));
	rep(i,0,len(v)){
		if (v[i] == 1) sum += k;
		k *= 2;
	}
	
	sum *= 2;
	k = 1;
	while (k*2 <= sum) k *= 2;
	v.clear();
	while (1) {
		if (sum >= k) {
			v.pb(1);
			sum -= k;
		} 
		else {
			v.pb(0);
		}
		if (k==1) break; 
		k /= 2;
	}

	string ans;
	rep(i,0,len(v)) {
		if (v[i] == 1) ans += "hamu";
		else ans += "ham";
	}
	cout << ans << endl;

	return 0;
}
0