結果

問題 No.600 かい文回
ユーザー ikd
提出日時 2017-11-26 12:07:21
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 97,596 KB
実行使用メモリ 14,204 KB
最終ジャッジ日時 2024-06-12 22:42:02
合計ジャッジ時間 4,986 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 4 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.array;

  int n; rd(n);
  
  char[] s=['a'];
  int k=1;
  while(k<n){
    if(k*2<=n){
      s=s[0]~s~s[$-1];
      k*=2;
    }else{
      for(char c='a'; c<='z'; c++){
        if(c!=s[0]){s=c~s~c; break;}
      }
      k+=1;
    }
  }

  writeln(s);
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
0