結果

問題 No.254 文字列の構成
ユーザー cielciel
提出日時 2015-07-25 00:02:30
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 314 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 11,484 KB
実行使用メモリ 16,008 KB
最終ジャッジ日時 2023-09-23 00:45:25
合計ジャッジ時間 6,991 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,612 KB
testcase_01 AC 86 ms
15,480 KB
testcase_02 AC 86 ms
15,420 KB
testcase_03 AC 86 ms
15,424 KB
testcase_04 AC 86 ms
15,584 KB
testcase_05 AC 87 ms
15,472 KB
testcase_06 AC 86 ms
15,408 KB
testcase_07 AC 87 ms
15,640 KB
testcase_08 AC 87 ms
15,508 KB
testcase_09 AC 87 ms
15,504 KB
testcase_10 AC 86 ms
15,404 KB
testcase_11 AC 86 ms
15,572 KB
testcase_12 AC 86 ms
15,288 KB
testcase_13 AC 86 ms
15,404 KB
testcase_14 AC 85 ms
15,580 KB
testcase_15 AC 86 ms
15,524 KB
testcase_16 AC 82 ms
15,428 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 87 ms
15,508 KB
testcase_23 AC 87 ms
15,304 KB
testcase_24 AC 88 ms
15,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 85 ms
15,412 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/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).chr+(97+2*i+1).chr)*(e-1) + (97+2*i).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)
0