結果

問題 No.377 背景パターン
ユーザー cielciel
提出日時 2021-06-15 00:21:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 3,044 ms / 5,000 ms
コード長 344 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 11,316 KB
実行使用メモリ 99,416 KB
最終ジャッジ日時 2023-08-26 14:29:31
合計ジャッジ時間 9,732 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
15,372 KB
testcase_01 AC 85 ms
15,484 KB
testcase_02 AC 85 ms
15,492 KB
testcase_03 AC 93 ms
15,536 KB
testcase_04 AC 85 ms
15,512 KB
testcase_05 AC 81 ms
15,308 KB
testcase_06 AC 79 ms
15,284 KB
testcase_07 AC 81 ms
15,188 KB
testcase_08 AC 85 ms
15,168 KB
testcase_09 AC 83 ms
15,432 KB
testcase_10 AC 79 ms
15,204 KB
testcase_11 AC 79 ms
15,384 KB
testcase_12 AC 82 ms
15,392 KB
testcase_13 AC 93 ms
15,648 KB
testcase_14 AC 90 ms
15,592 KB
testcase_15 AC 83 ms
15,280 KB
testcase_16 AC 2,968 ms
97,752 KB
testcase_17 AC 3,044 ms
99,416 KB
testcase_18 AC 89 ms
15,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require'prime'
def x(a,d=0,n=1,t=1,&b)d==a.size ? b.(n,t):(0..a[d][1]).map{|i|x(a,d+1,n*a[d][0]**i,i>0?t*~-a[d][0]*a[d][0]**~-i:t,&b)}end
q=->x,y{z=1;(y%2>0&&z=z*x%M;x=x*x%M;y/=2)while y>0;z}
C={}
r=M=10**9+7
H,W,K=gets.split.map &:to_i
x(H.prime_division){|a,c|x(W.prime_division){|b,d|r=(r+c*d*C[k=W*H/a.lcm(b)]||=q[K,k])%M}}
p r*q[W*H,M-2]%M
0