結果
問題 |
No.701 ひとりしりとり
|
ユーザー |
|
提出日時 | 2019-01-17 16:18:19 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 854 bytes |
コンパイル時間 | 3,200 ms |
コンパイル使用メモリ | 64,932 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 10:05:59 |
合計ジャッジ時間 | 3,821 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
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')