結果

問題 No.886 Direct
ユーザー tempura_pp
提出日時 2019-08-20 18:36:45
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 599 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 82,108 KB
実行使用メモリ 140,928 KB
最終ジャッジ日時 2024-10-06 12:43:38
合計ジャッジ時間 4,305 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 3
other RE * 32
権限があれば一括ダウンロードができます

ソースコード

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*cnt1[1]+h*(w-1)+w*(h-1))%(10**9+7))
0