結果

問題 No.701 ひとりしりとり
ユーザー むらためむらため
提出日時 2019-01-17 16:18:19
言語 Nim
(2.0.2)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 854 bytes
コンパイル時間 2,977 ms
コンパイル使用メモリ 68,248 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:00:06
合計ジャッジ時間 4,031 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

const bound = 'z'.ord - 'a'.ord# [0,bound] まで使える
proc getAsciis(a:int): string =
  if a == 0: return "a"
  result = ""
  var n = a
  while n > 0:
    var c = chr('a'.ord + (n mod bound))
    if c == 'n' : c = 'z'
    result &= c
    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)
  if n mod 2 == 0 and i == n div 2 - 1:
    putchar_unlocked('n')
  else: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('n')
  putchar_unlocked('\n')
0