結果

問題 No.368 LCM of K-products
ユーザー urutomurutom
提出日時 2016-04-29 23:35:01
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 251 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-15 06:02:25
合計ジャッジ時間 4,231 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 83 ms
12,416 KB
testcase_02 AC 81 ms
12,160 KB
testcase_03 AC 79 ms
12,160 KB
testcase_04 AC 81 ms
12,288 KB
testcase_05 AC 80 ms
12,288 KB
testcase_06 AC 79 ms
12,416 KB
testcase_07 AC 79 ms
12,160 KB
testcase_08 AC 81 ms
12,288 KB
testcase_09 AC 80 ms
12,288 KB
testcase_10 AC 81 ms
12,416 KB
testcase_11 WA -
testcase_12 AC 82 ms
12,288 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 80 ms
12,160 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 82 ms
12,288 KB
testcase_24 AC 79 ms
12,416 KB
testcase_25 WA -
testcase_26 AC 79 ms
12,416 KB
testcase_27 AC 79 ms
12,416 KB
testcase_28 AC 77 ms
12,160 KB
testcase_29 AC 80 ms
12,288 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 79 ms
12,160 KB
testcase_33 WA -
testcase_34 AC 79 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:13: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

M=10**9+7

def powmod(a,p)
	prod=1
	while p>0
		prod=(prod*a)%M if p.odd?
		a=(a*a)%M
		p/=2
	end
	prod
end

n,k,*a=gets(p).split.map(&:to_i)
gcd=a.first
a.each{|v|gcd=v.gcd gcd}
prod=a.map{|v|v/gcd}.inject(1){|r,v|(r*v)%M}
puts (powmod(gcd,k)*prod)%M
0