結果

問題 No.886 Direct
ユーザー shotoyooshotoyoo
提出日時 2020-11-21 12:48:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,949 ms / 4,000 ms
コード長 544 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 86,812 KB
実行使用メモリ 148,360 KB
最終ジャッジ日時 2023-09-30 21:44:22
合計ジャッジ時間 23,297 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,208 KB
testcase_01 AC 71 ms
71,408 KB
testcase_02 AC 71 ms
71,028 KB
testcase_03 AC 86 ms
76,512 KB
testcase_04 AC 71 ms
71,452 KB
testcase_05 AC 72 ms
71,508 KB
testcase_06 AC 72 ms
71,296 KB
testcase_07 AC 72 ms
71,320 KB
testcase_08 AC 72 ms
71,340 KB
testcase_09 AC 71 ms
71,028 KB
testcase_10 AC 72 ms
71,268 KB
testcase_11 AC 72 ms
71,412 KB
testcase_12 AC 72 ms
71,216 KB
testcase_13 AC 71 ms
71,388 KB
testcase_14 AC 71 ms
71,332 KB
testcase_15 AC 72 ms
71,396 KB
testcase_16 AC 72 ms
71,224 KB
testcase_17 AC 87 ms
76,600 KB
testcase_18 AC 94 ms
76,756 KB
testcase_19 AC 92 ms
76,528 KB
testcase_20 AC 88 ms
76,740 KB
testcase_21 AC 84 ms
76,224 KB
testcase_22 AC 93 ms
76,900 KB
testcase_23 AC 277 ms
87,040 KB
testcase_24 AC 771 ms
100,916 KB
testcase_25 AC 260 ms
86,116 KB
testcase_26 AC 215 ms
84,132 KB
testcase_27 AC 1,552 ms
117,120 KB
testcase_28 AC 1,552 ms
118,236 KB
testcase_29 AC 72 ms
71,220 KB
testcase_30 AC 73 ms
71,032 KB
testcase_31 AC 2,857 ms
148,056 KB
testcase_32 AC 2,949 ms
148,220 KB
testcase_33 AC 2,888 ms
148,360 KB
testcase_34 AC 2,828 ms
148,200 KB
testcase_35 AC 2,901 ms
148,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

h,w = list(map(int, input().split()))
m = min(h,w)
f = [None]*(m+1)
M = 10**9+7
def subh(k):
    num = h//k
    return h*num - (k + num*k)*num//2
def subw(k):
    num = w//k
    return w*num - (k + num*k)*num//2
for k in range(m, 0, -1):
    f[k] = subh(k)*subw(k)
    for i in range(2, (m//k)+1):
        f[k] -= f[i*k]
        f[k] %= M
    f[k] %= M
ans = (f[1]*2 + (h-1)*w + h*(w-1))%M
print(ans%M)
0