結果

問題 No.254 文字列の構成
ユーザー cielciel
提出日時 2015-07-25 00:08:32
言語 Ruby
(3.3.0)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 330 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 11,540 KB
実行使用メモリ 17,108 KB
最終ジャッジ日時 2023-08-27 05:37:54
合計ジャッジ時間 5,757 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
16,832 KB
testcase_01 AC 114 ms
17,036 KB
testcase_02 AC 112 ms
16,904 KB
testcase_03 AC 112 ms
16,960 KB
testcase_04 AC 115 ms
16,996 KB
testcase_05 AC 115 ms
17,036 KB
testcase_06 AC 113 ms
16,948 KB
testcase_07 AC 114 ms
16,724 KB
testcase_08 AC 112 ms
16,860 KB
testcase_09 AC 116 ms
16,948 KB
testcase_10 AC 114 ms
16,952 KB
testcase_11 AC 112 ms
16,900 KB
testcase_12 AC 110 ms
17,008 KB
testcase_13 AC 113 ms
16,948 KB
testcase_14 AC 112 ms
16,684 KB
testcase_15 AC 112 ms
17,108 KB
testcase_16 AC 112 ms
16,956 KB
testcase_17 AC 114 ms
16,996 KB
testcase_18 AC 113 ms
16,940 KB
testcase_19 AC 114 ms
17,004 KB
testcase_20 AC 115 ms
16,900 KB
testcase_21 AC 114 ms
16,684 KB
testcase_22 AC 112 ms
16,928 KB
testcase_23 AC 112 ms
16,960 KB
testcase_24 AC 113 ms
16,824 KB
testcase_25 AC 114 ms
16,868 KB
testcase_26 AC 114 ms
16,832 KB
testcase_27 AC 114 ms
17,004 KB
testcase_28 AC 114 ms
17,068 KB
testcase_29 AC 114 ms
16,684 KB
testcase_30 AC 114 ms
16,996 KB
testcase_31 AC 115 ms
16,824 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/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)
0