結果

問題 No.886 Direct
ユーザー tempura_pptempura_pp
提出日時 2019-08-20 18:44:25
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,416 ms / 4,000 ms
コード長 609 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 320,004 KB
最終ジャッジ日時 2023-07-28 18:33:46
合計ジャッジ時間 17,222 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,272 KB
testcase_01 AC 72 ms
71,236 KB
testcase_02 AC 70 ms
71,100 KB
testcase_03 AC 92 ms
76,684 KB
testcase_04 AC 71 ms
71,260 KB
testcase_05 AC 71 ms
71,416 KB
testcase_06 AC 70 ms
71,328 KB
testcase_07 AC 69 ms
71,092 KB
testcase_08 AC 70 ms
71,356 KB
testcase_09 AC 70 ms
71,376 KB
testcase_10 AC 70 ms
71,436 KB
testcase_11 AC 70 ms
71,444 KB
testcase_12 AC 69 ms
71,384 KB
testcase_13 AC 69 ms
71,292 KB
testcase_14 AC 69 ms
71,480 KB
testcase_15 AC 69 ms
71,404 KB
testcase_16 AC 70 ms
71,240 KB
testcase_17 AC 88 ms
76,624 KB
testcase_18 AC 89 ms
77,476 KB
testcase_19 AC 89 ms
77,376 KB
testcase_20 AC 89 ms
76,560 KB
testcase_21 AC 89 ms
77,476 KB
testcase_22 AC 88 ms
77,276 KB
testcase_23 AC 559 ms
215,964 KB
testcase_24 AC 625 ms
207,136 KB
testcase_25 AC 351 ms
183,312 KB
testcase_26 AC 472 ms
192,784 KB
testcase_27 AC 1,344 ms
314,564 KB
testcase_28 AC 1,414 ms
310,772 KB
testcase_29 AC 586 ms
174,932 KB
testcase_30 AC 604 ms
175,052 KB
testcase_31 AC 1,389 ms
319,728 KB
testcase_32 AC 1,353 ms
319,920 KB
testcase_33 AC 1,416 ms
319,768 KB
testcase_34 AC 1,289 ms
319,620 KB
testcase_35 AC 1,326 ms
320,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int,input().split())
n = max(h+1, w+1)
cnt1 = [max(0,h-i) for i in range(n)]
cnt2 = [max(0,w-i) for i in range(n)]
isprime = [1]*n
isprime[0]=0
isprime[1]=0
prime = []
for i,b in enumerate(isprime):
    if b == 0: continue
    prime.append(i)
    j = 2*i
    while j < n :
        isprime[j] = 0
        j += i
for p in prime :
    m = (n-1)//p
    for i in range(m,0,-1):
        cnt1[i]+=cnt1[i*p]
        cnt2[i]+=cnt2[i*p]
cnt = [cnt1[i]*cnt2[i] for i in range(n)]
for p in prime :
    m = (n-1)//p
    for i in range(1,m+1):
        cnt[i]-=cnt[i*p]
print((2*cnt[1]+h*(w-1)+w*(h-1))%(10**9+7))
0