結果

問題 No.886 Direct
ユーザー ああいいああいい
提出日時 2022-03-01 11:38:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 947 ms / 4,000 ms
コード長 653 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 286,780 KB
最終ジャッジ日時 2023-09-21 22:57:28
合計ジャッジ時間 14,016 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,020 KB
testcase_01 AC 71 ms
71,472 KB
testcase_02 AC 72 ms
71,584 KB
testcase_03 AC 94 ms
77,172 KB
testcase_04 AC 71 ms
71,312 KB
testcase_05 AC 72 ms
71,392 KB
testcase_06 AC 72 ms
71,240 KB
testcase_07 AC 72 ms
70,988 KB
testcase_08 AC 71 ms
71,472 KB
testcase_09 AC 73 ms
71,024 KB
testcase_10 AC 71 ms
71,472 KB
testcase_11 AC 72 ms
71,552 KB
testcase_12 AC 72 ms
71,572 KB
testcase_13 AC 73 ms
71,224 KB
testcase_14 AC 73 ms
71,412 KB
testcase_15 AC 73 ms
71,488 KB
testcase_16 AC 73 ms
71,396 KB
testcase_17 AC 95 ms
77,840 KB
testcase_18 AC 100 ms
79,320 KB
testcase_19 AC 98 ms
78,372 KB
testcase_20 AC 96 ms
77,524 KB
testcase_21 AC 100 ms
79,952 KB
testcase_22 AC 99 ms
79,052 KB
testcase_23 AC 421 ms
220,824 KB
testcase_24 AC 452 ms
224,084 KB
testcase_25 AC 282 ms
169,332 KB
testcase_26 AC 371 ms
205,124 KB
testcase_27 AC 848 ms
268,420 KB
testcase_28 AC 784 ms
282,576 KB
testcase_29 AC 873 ms
267,468 KB
testcase_30 AC 857 ms
268,492 KB
testcase_31 AC 924 ms
286,132 KB
testcase_32 AC 947 ms
286,312 KB
testcase_33 AC 893 ms
285,944 KB
testcase_34 AC 876 ms
285,716 KB
testcase_35 AC 861 ms
286,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int,input().split())
C = max(H,W)+1
dat = [0] * C
h = [0] + [H - i for i in range(1,H)] + [0] * (C - H)
w = [0] + [W - i for i in range(1,W)] + [0] * (C - W)

prime = set()
P = 10 ** 9 + 7
for i in range(2,C):
    if dat[i] == 0:
        for j in range(2 * i,C,i):
            dat[j] = 1
        prime.add(i)
for p in prime:
    for j in range((C-1)//p,0,-1):
        h[j] += h[j*p]
        h[j] %= P
        w[j] += w[j*p]
        w[j] %= P
z = [i * j % P for i,j in zip(h,w)]

for p in prime:
    if p > C - 1:break
    for j in range(1,(C-1)//p+1):
        z[j] -= z[j*p]
ans = z[1] * 2 % P + (H-1) * W % P + (W - 1) * H % P
print(ans % P)
0