結果
| 問題 |
No.254 文字列の構成
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-25 00:04:24 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 329 bytes |
| コンパイル時間 | 245 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2024-07-16 01:53:12 |
| 合計ジャッジ時間 | 6,499 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 WA * 11 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/bin/ruby
M=10000
A=(1..M).map{|i|i*i}.reverse
def dfs(lst,n,last)
if n==0
puts lst.each_with_index.map{|e,i|((97+(2*i)%26).chr+(97+(2*i+1)%26).chr)*(e-1) + (97+(2*i)%26).chr}*''
exit
else
last.step(A.size-1){|i|
d,r=n.divmod(A[i])
if d>0
dfs(lst+[M-i]*d,r,i+1)
end
}
end
end
N=gets.to_i
dfs([],N,0)