結果

問題 No.886 Direct
ユーザー tempura_pptempura_pp
提出日時 2019-08-20 18:44:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,606 ms / 4,000 ms
コード長 609 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 319,528 KB
最終ジャッジ日時 2024-04-16 02:33:42
合計ジャッジ時間 16,406 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
51,840 KB
testcase_01 AC 46 ms
52,224 KB
testcase_02 AC 42 ms
51,968 KB
testcase_03 AC 66 ms
65,664 KB
testcase_04 AC 42 ms
51,712 KB
testcase_05 AC 42 ms
52,096 KB
testcase_06 AC 42 ms
51,840 KB
testcase_07 AC 42 ms
52,096 KB
testcase_08 AC 42 ms
51,840 KB
testcase_09 AC 42 ms
52,096 KB
testcase_10 AC 42 ms
51,840 KB
testcase_11 AC 42 ms
51,712 KB
testcase_12 AC 42 ms
51,968 KB
testcase_13 AC 42 ms
51,712 KB
testcase_14 AC 42 ms
51,968 KB
testcase_15 AC 43 ms
51,712 KB
testcase_16 AC 42 ms
51,584 KB
testcase_17 AC 67 ms
66,048 KB
testcase_18 AC 68 ms
66,688 KB
testcase_19 AC 67 ms
65,920 KB
testcase_20 AC 66 ms
65,664 KB
testcase_21 AC 69 ms
67,072 KB
testcase_22 AC 67 ms
65,792 KB
testcase_23 AC 611 ms
206,120 KB
testcase_24 AC 694 ms
218,088 KB
testcase_25 AC 418 ms
182,052 KB
testcase_26 AC 544 ms
184,960 KB
testcase_27 AC 1,433 ms
316,232 KB
testcase_28 AC 1,395 ms
294,792 KB
testcase_29 AC 653 ms
184,960 KB
testcase_30 AC 638 ms
184,704 KB
testcase_31 AC 1,435 ms
318,920 KB
testcase_32 AC 1,487 ms
319,528 KB
testcase_33 AC 1,579 ms
319,032 KB
testcase_34 AC 1,606 ms
319,156 KB
testcase_35 AC 1,434 ms
319,056 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