結果
| 問題 | No.254 文字列の構成 |
| コンテスト | |
| ユーザー |
yuruhiya
|
| 提出日時 | 2021-07-29 14:43:55 |
| 言語 | Crystal (1.19.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 366 bytes |
| 記録 | |
| コンパイル時間 | 9,829 ms |
| コンパイル使用メモリ | 338,784 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-04 12:26:44 |
| 合計ジャッジ時間 | 10,912 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
def square(n : Int32)
sqrt = Math.sqrt(n).to_i + 1
while sqrt * sqrt > n
sqrt -= 1
end
sqrt
end
n = read_line.to_i
a = [] of Int32
while n > 0
s = square(n)
a << s - 1
n -= s * s
end
now = 'a'
puts a.map_with_index { |x, i|
if x == 0
now.tap { now += 1 }
else
c1, c2 = now, now + 1
now += 2
"#{c1}#{c2}" * x + c1
end
}.join
yuruhiya