結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー norioc
提出日時 2025-03-17 23:40:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 1,000 ms
コード長 435 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 82,780 KB
実行使用メモリ 54,104 KB
最終ジャッジ日時 2025-03-17 23:40:51
合計ジャッジ時間 3,176 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations
from math import lcm


def f(n: int, vs: list[int]) -> int:
    res = 0
    for i in range(1, len(vs)+1):
        for cs in combinations(vs, i):
            x = 1
            for c in cs:
                x = lcm(x, c)

            sgn = 1 if i % 2 == 1 else -1
            res += sgn * (n // x)

    return res


N = int(input())
A, B, C = map(int, input().split())

ans = f(N, [A, B, C])
print(ans)
0