結果

問題 No.423 ハムスター語初級(数詞)
ユーザー HO_RI1991HO_RI1991
提出日時 2016-09-22 22:33:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 90,984 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 01:42:12
合計ジャッジ時間 1,315 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main() {
	string str;
	cin>>str;
	long long num=0;
	int index=0;
	while(index<str.size()){
		if(str.substr(index,4)=="hamu"){
			num+=1;
			index+=4;
		}
		else{
			index+=3;
		}
		if(index<str.size())num<<=1;
	}

	num*=2;
	if(num==0){
		cout<<"ham"<<endl;
	}
	else{
		long long tmp=num;
		int cnt=0;
		while(tmp>0){
			++cnt;
			tmp>>=1;
		}

		for(int i=cnt-1;i>=0;--i){
			if(num&(1<<i))cout<<"hamu";
			else cout<<"ham";
		}
		cout<<endl;
	}

	//system("pause");
	return 0;
}
0