結果

問題 No.600 かい文回
ユーザー mtsdmtsd
提出日時 2017-11-24 22:57:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,189 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 77,636 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 11:19:29
合計ジャッジ時間 4,362 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007

int main(){
	ll n;
	cin >> n;
	if(n==1){
		cout << "a" << endl;
		return 0;
	}
	vector<int>v;
	while(n!=0){
		ll x = 1;
		for(int i=0;i<100;i++){
			if(x>n){
				v.push_back(i-1);
				n -= x/2;
				break;
			}else{
				x*=2;
			}
		}
	}
	string s;
	if(v.size()==1){
		for(int i=0;i<v[0];i++){
			s.push_back('a');
		}
		s += s;
		cout << s << endl;
	}else{
		v.push_back(0);
		reverse(v.begin(),v.end());
		for(int i=1;i<v.size();i++){
			if(i!=((int)v.size()-1)){
				for(int j=0;j<v[i]-v[i-1]+1;j++){
					if(i%2==1){
						s.push_back('a');	
					}else{
						s.push_back('b');
					}
				}
			}else{
				for(int j=0;j<v[i]-v[i-1];j++){
					if(i%2==1){
						s.push_back('a');	
					}else{
						s.push_back('b');
					}
				}
			}
		}
		string tmp = s;
		reverse(tmp.begin(),tmp.end());
		s += tmp;
		cout << s << endl;
	}
	return 0;
}
0