結果

問題 No.377 背景パターン
ユーザー cielciel
提出日時 2016-06-05 01:54:27
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 770 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 76,288 KB
実行使用メモリ 92,032 KB
最終ジャッジ日時 2024-04-17 03:47:51
合計ジャッジ時間 11,661 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 189 ms
90,496 KB
testcase_01 AC 187 ms
90,624 KB
testcase_02 AC 194 ms
91,008 KB
testcase_03 AC 185 ms
90,624 KB
testcase_04 AC 181 ms
90,368 KB
testcase_05 AC 179 ms
90,624 KB
testcase_06 AC 206 ms
90,624 KB
testcase_07 AC 187 ms
90,496 KB
testcase_08 AC 185 ms
90,624 KB
testcase_09 AC 187 ms
90,496 KB
testcase_10 AC 184 ms
90,624 KB
testcase_11 AC 188 ms
90,496 KB
testcase_12 AC 192 ms
90,624 KB
testcase_13 AC 273 ms
92,032 KB
testcase_14 AC 260 ms
91,904 KB
testcase_15 AC 189 ms
90,496 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
from collections import defaultdict
from fractions import gcd
import subprocess
import sys
if sys.version_info[0]>=3:
	raw_input=input
	xrange=range

def prime_division(n):
	h=defaultdict(int)
	line=subprocess.check_output(['factor',str(n)])
	for e in line.split()[1:]: h[int(e)]+=1
	return [(k,v) for k,v in h.items()]

def divisor(a,d,n,t):
	if d==len(a):
		yield (n,t)
	else:
		for i in xrange(a[d][1]+1):
			for x,xt in divisor(
				a,d+1,
				n*a[d][0]**i,
				(t if i==0 else t*(a[d][0]-1)*a[d][0]**(i-1))
			): yield (x,xt)

M=1000000007
H,W,K=map(int,raw_input().split())
A=prime_division(H)
B=prime_division(W)
r=0
for a,at in divisor(A,0,1,1):
	for b,bt in divisor(B,0,1,1):
		r=(r+at*bt*pow(K,W*H*gcd(a,b)/a/b,M))%M
print(r*pow(W*H,M-2,M)%M)
0