結果

問題 No.473 和と積の和
ユーザー cielciel
提出日時 2016-12-24 14:57:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 2,129 ms / 3,000 ms
コード長 327 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 11,308 KB
実行使用メモリ 26,188 KB
最終ジャッジ日時 2023-08-22 09:12:20
合計ジャッジ時間 18,575 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
15,024 KB
testcase_01 AC 93 ms
15,324 KB
testcase_02 AC 92 ms
15,056 KB
testcase_03 AC 826 ms
20,232 KB
testcase_04 AC 91 ms
15,368 KB
testcase_05 AC 90 ms
15,316 KB
testcase_06 AC 91 ms
15,312 KB
testcase_07 AC 92 ms
15,328 KB
testcase_08 AC 91 ms
15,136 KB
testcase_09 AC 92 ms
15,516 KB
testcase_10 AC 92 ms
15,444 KB
testcase_11 AC 92 ms
15,340 KB
testcase_12 AC 91 ms
15,168 KB
testcase_13 AC 92 ms
15,300 KB
testcase_14 AC 91 ms
15,336 KB
testcase_15 AC 91 ms
15,476 KB
testcase_16 AC 90 ms
15,516 KB
testcase_17 AC 90 ms
15,456 KB
testcase_18 AC 92 ms
15,244 KB
testcase_19 AC 90 ms
15,208 KB
testcase_20 AC 92 ms
15,168 KB
testcase_21 AC 92 ms
15,148 KB
testcase_22 AC 93 ms
15,316 KB
testcase_23 AC 102 ms
15,324 KB
testcase_24 AC 106 ms
15,544 KB
testcase_25 AC 2,129 ms
26,188 KB
testcase_26 AC 624 ms
19,552 KB
testcase_27 AC 717 ms
20,516 KB
testcase_28 AC 91 ms
15,380 KB
testcase_29 AC 93 ms
15,332 KB
testcase_30 AC 94 ms
15,508 KB
testcase_31 AC 94 ms
15,372 KB
testcase_32 AC 93 ms
15,436 KB
testcase_33 AC 90 ms
15,292 KB
testcase_34 AC 1,323 ms
23,472 KB
testcase_35 AC 1,322 ms
24,508 KB
testcase_36 AC 93 ms
15,328 KB
testcase_37 AC 92 ms
15,292 KB
testcase_38 AC 1,289 ms
24,380 KB
testcase_39 AC 748 ms
20,504 KB
testcase_40 AC 750 ms
20,264 KB
testcase_41 AC 757 ms
20,272 KB
testcase_42 AC 175 ms
15,484 KB
testcase_43 AC 868 ms
20,048 KB
testcase_44 AC 1,304 ms
24,668 KB
testcase_45 AC 90 ms
15,172 KB
testcase_46 AC 90 ms
15,180 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.shift.product(*a).map{|e|e.reduce(:*)}.sort[1..-1].reverse
m={}
f=->x,n,d,a{
return 1 if x==1&&n==0
return 0 if x==1||n==0
m[[x,n,d]]||=lambda{
r=0
(d...a.size).each{|i|r+=f.(x/a[i],n-1,i,a) if x%a[i]==0}
r
}.()
}
p f.(x+1,n,0,b)
0