結果

問題 No.473 和と積の和
ユーザー cielciel
提出日時 2016-12-24 15:28:35
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,709 ms / 3,000 ms
コード長 275 bytes
コンパイル時間 64 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-05-09 14:50:57
合計ジャッジ時間 16,837 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
12,288 KB
testcase_01 AC 84 ms
12,160 KB
testcase_02 AC 85 ms
12,160 KB
testcase_03 AC 725 ms
18,560 KB
testcase_04 AC 82 ms
12,416 KB
testcase_05 AC 79 ms
12,288 KB
testcase_06 AC 79 ms
12,416 KB
testcase_07 AC 80 ms
12,416 KB
testcase_08 AC 86 ms
12,416 KB
testcase_09 AC 81 ms
12,416 KB
testcase_10 AC 81 ms
12,416 KB
testcase_11 AC 80 ms
12,288 KB
testcase_12 AC 81 ms
12,416 KB
testcase_13 AC 85 ms
12,544 KB
testcase_14 AC 82 ms
12,288 KB
testcase_15 AC 80 ms
12,160 KB
testcase_16 AC 80 ms
12,288 KB
testcase_17 AC 80 ms
12,160 KB
testcase_18 AC 80 ms
12,288 KB
testcase_19 AC 79 ms
12,160 KB
testcase_20 AC 80 ms
12,416 KB
testcase_21 AC 81 ms
12,288 KB
testcase_22 AC 80 ms
12,160 KB
testcase_23 AC 89 ms
12,544 KB
testcase_24 AC 95 ms
12,672 KB
testcase_25 AC 1,709 ms
26,752 KB
testcase_26 AC 555 ms
17,408 KB
testcase_27 AC 625 ms
17,536 KB
testcase_28 AC 81 ms
12,416 KB
testcase_29 AC 82 ms
12,672 KB
testcase_30 AC 82 ms
12,416 KB
testcase_31 AC 80 ms
12,416 KB
testcase_32 AC 82 ms
12,672 KB
testcase_33 AC 82 ms
12,544 KB
testcase_34 AC 1,094 ms
22,784 KB
testcase_35 AC 1,112 ms
22,656 KB
testcase_36 AC 84 ms
12,544 KB
testcase_37 AC 82 ms
12,544 KB
testcase_38 AC 1,108 ms
22,400 KB
testcase_39 AC 748 ms
17,792 KB
testcase_40 AC 644 ms
18,048 KB
testcase_41 AC 646 ms
17,664 KB
testcase_42 AC 1,250 ms
23,936 KB
testcase_43 AC 1,249 ms
24,320 KB
testcase_44 AC 1,274 ms
24,576 KB
testcase_45 AC 82 ms
12,160 KB
testcase_46 AC 81 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require'prime'
n,x=gets.split.map &:to_i
a=(x+=1).prime_division.map{|k,v|(0..v).map{|i|k**i}}
b=a.pop.product(*a).map{|e|e.reduce :*}.sort[1..-1].reverse
m={}
f=->x,n,d,a{x<2&&n==0?1:m[[x,n,d]]||=->{r=0;(d...a.size).each{|i|x%a[i]>0||r+=f[x/a[i],n-1,i,a]};r}[]}
p f[x,n,0,b]
0