結果

問題 No.600 かい文回
ユーザー ikd
提出日時 2017-11-26 12:39:55
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 98,768 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 22:42:13
合計ジャッジ時間 1,586 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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

  int n; rd(n);
  
  char cur='b';
  char[] fun(int m){
    if(m==1) return ['a'];
    char[] ret;
    if(m&1){
      ret=fun(m-1);
      ret=cur~ret~cur;
      if((++cur)>'z') cur='a';
    }else{
      ret=fun(m/2);
      ret=ret[0]~ret~ret[$-1];
    }
    return ret;
  }

  writeln(fun(n));
}


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