結果

問題 No.886 Direct
ユーザー shotoyooshotoyoo
提出日時 2020-11-21 12:50:51
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 542 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 148,420 KB
最終ジャッジ日時 2023-09-30 21:45:28
合計ジャッジ時間 29,856 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,316 KB
testcase_01 AC 71 ms
71,148 KB
testcase_02 AC 74 ms
71,408 KB
testcase_03 AC 86 ms
76,568 KB
testcase_04 AC 73 ms
71,404 KB
testcase_05 AC 72 ms
71,492 KB
testcase_06 AC 72 ms
71,284 KB
testcase_07 AC 72 ms
71,552 KB
testcase_08 AC 73 ms
71,468 KB
testcase_09 AC 71 ms
71,288 KB
testcase_10 AC 71 ms
71,456 KB
testcase_11 AC 72 ms
71,428 KB
testcase_12 AC 73 ms
71,492 KB
testcase_13 AC 73 ms
71,272 KB
testcase_14 AC 72 ms
71,460 KB
testcase_15 AC 73 ms
71,296 KB
testcase_16 AC 71 ms
71,168 KB
testcase_17 AC 88 ms
76,828 KB
testcase_18 AC 92 ms
76,904 KB
testcase_19 AC 91 ms
76,532 KB
testcase_20 AC 88 ms
76,616 KB
testcase_21 AC 85 ms
76,724 KB
testcase_22 AC 93 ms
76,600 KB
testcase_23 AC 365 ms
87,164 KB
testcase_24 AC 1,118 ms
101,004 KB
testcase_25 AC 335 ms
86,132 KB
testcase_26 AC 272 ms
84,496 KB
testcase_27 AC 2,021 ms
117,036 KB
testcase_28 AC 2,046 ms
118,160 KB
testcase_29 AC 72 ms
71,516 KB
testcase_30 AC 73 ms
71,432 KB
testcase_31 AC 3,864 ms
148,292 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 AC 3,977 ms
148,140 KB
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

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*k, m+1, k):
        f[k] -= f[i]
        f[k] %= M
    f[k] %= M
ans = (f[1]*2 + (h-1)*w + h*(w-1))%M
print(ans%M)
0