結果
問題 | No.254 文字列の構成 |
ユーザー | ciel |
提出日時 | 2015-07-25 00:08:32 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 129 ms / 5,000 ms |
コード長 | 330 bytes |
コンパイル時間 | 166 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 13,952 KB |
最終ジャッジ日時 | 2024-12-26 15:07:25 |
合計ジャッジ時間 | 5,918 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/bin/ruby M=100000 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)