結果

問題 No.701 ひとりしりとり
ユーザー むらためむらため
提出日時 2019-01-17 16:15:30
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 748 bytes
コンパイル時間 3,023 ms
コンパイル使用メモリ 68,464 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 01:59:58
合計ジャッジ時間 5,403 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils
proc putchar_unlocked(c:char){.header: "<stdio.h>" .}

const bound = 'z'.ord - 'a'.ord + 1# [0,bound] まで使える
proc getAsciis(a:int): string =
  if a == 0: return "a"
  result = ""
  var n = a
  while n > 0:
    result &= chr('a'.ord + (n mod bound))
    n = n div bound

let n = stdin.readLine().parseInt()
for i in 0..<n div 2:
  let S = i.getAsciis()
  putchar_unlocked('a')
  for s in S: putchar_unlocked(s)
  putchar_unlocked('b')
  putchar_unlocked('\n')
  putchar_unlocked('b')
  for s in S: putchar_unlocked(s)
  putchar_unlocked('a')
  putchar_unlocked('\n')

if n mod 2 == 1:
  let S = (n div 2).getAsciis()
  putchar_unlocked('a')
  for s in S: putchar_unlocked(s)
  putchar_unlocked('b')
  putchar_unlocked('\n')
0