結果

問題 No.600 かい文回
ユーザー mtsdmtsd
提出日時 2017-11-24 23:00:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,233 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 77,712 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 05:06:22
合計ジャッジ時間 1,860 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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('a'+i-1>'z'){
						s.push_back('a'+('a'+i-1-'z'));
					}else{
						s.push_back('a'+i-1);
					}
				}
			}else{
				for(int j=0;j<v[i]-v[i-1];j++){
					if('a'+i-1>'z'){
						s.push_back('a'+('a'+i-1-'z'));
					}else{
						s.push_back('a'+i-1);
					}
				}
			}
		}
		string tmp = s;
		reverse(tmp.begin(),tmp.end());
		s += tmp;
		cout << s << endl;
	}
	return 0;
}
0