結果

問題 No.600 かい文回
ユーザー kotatsugamekotatsugame
提出日時 2020-03-09 16:50:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 727 ms
コンパイル使用メモリ 75,368 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-08 01:49:38
合計ジャッジ時間 1,832 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
string s;
int N;
main()
{
	cin>>N;
	if(N==1)
	{
	    cout<<"a"<<endl;
	    return 0;
	}
	vector<int>bit;
	while(N)
	{
		bit.push_back(N%2);
		N>>=1;
	}
	reverse(bit.begin(),bit.end());
	int cnt=0;
	for(int i=0;i<bit.size();cnt++)
	{
		int j=i+1;
		while(j<bit.size()&&bit[j]==0)j++;
		int t=j-i;
		i=j;
		if(i<bit.size())t++;
		if(cnt==0)t--;
		s+=string(t,cnt%26+'a');
	}
	string t=s;
	reverse(t.begin(),t.end());
	cout<<t+s<<endl;
}
0