結果

問題 No.3152 neither multiple of A nor B
ユーザー しもりん
提出日時 2025-06-19 07:21:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 864 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 82,648 KB
実行使用メモリ 68,352 KB
最終ジャッジ日時 2025-06-19 07:21:18
合計ジャッジ時間 5,455 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush, nlargest, nsmallest
from bisect import bisect_left, bisect, bisect_right
from copy import deepcopy
from time import perf_counter
import sys
from typing import Any, List, Callable


def debug(*args, sep=" ", end="\n") -> None:
    print(*args, sep=sep, end=end, file=sys.stderr)


def gcd(a, b):
    a = abs(a); b = abs(b)
    if a < b: a, b = b, a
    while b > 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // (gcd(a, b))


def main():
    global inf, MOD
    input = sys.stdin.read().split()
    ptr = 0
    inf = float("inf")
    MOD = 998244353

    n, a, b = map(int, input[ptr:ptr + 3]); ptr += 3
    l = lcm(a, b)
    debug(a, b, l)
    ans = n - (n // a + n // b - (n // l))
    print(ans)


if __name__ == "__main__":
    main()
0