結果

問題 No.600 かい文回
ユーザー koyumeishi
提出日時 2016-06-03 20:45:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 65,920 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-08 06:43:45
合計ジャッジ時間 3,533 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cassert>
using namespace std;
int main(){
  long long x; cin >> x;
  assert(1<=x && x<=1000000000);

  if(x==1){
    puts("a");
    return 0;
  }

  string ch  = "ab";
  string ans = "";

  long long k = 0;
  while((1LL<<k) <= x) k++;

  int i = 0;
  for(k-=2; k>=0; k--){
    ans += ch[i%2];

    if((x>>k)&1){
      i++;
      ans += ch[i%2];
    }
  }

  cout << string(ans.rbegin(), ans.rend()) << ans << endl;
  return 0;
}
0