結果

問題 No.3687 Coprime Count
コンテスト
ユーザー detteiuu
提出日時 2026-09-06 21:58:55
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,314 ms / 2,000 ms
+ 346µs
コード長 666 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,376 ms
コンパイル使用メモリ 96,080 KB
実行使用メモリ 240,128 KB
最終ジャッジ日時 2026-09-06 21:59:16
合計ジャッジ時間 7,456 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

class Eratosthenes:
    def __init__(self, n):
        self.isPrime = [True]*(n+1)
        self.isPrime[0], self.isPrime[1] = False, False
        self.mobius = [1]*(n+1)
        for i in range(2, n+1):
            if self.isPrime[i]:
                self.mobius[i] = -1
                for j in range(i*2, n+1, i):
                    self.isPrime[j] = False
                    if j//i%i == 0:
                        self.mobius[j] = 0
                    else:
                        self.mobius[j] *= -1

N, M = map(int, input().split())

MIN = min(N, M)

E = Eratosthenes(MIN)
ans = 0
for n in range(1, MIN+1):
    ans += (N//n)*(M//n)*E.mobius[n]

print(ans)
0