結果

問題 No.316 もっと刺激的なFizzBuzzをください
コンテスト
ユーザー FromBooska
提出日時 2023-02-27 22:10:51
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 65 ms / 1,000 ms
+ 995µs
コード長 503 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 245 ms
コンパイル使用メモリ 96,620 KB
実行使用メモリ 79,104 KB
最終ジャッジ日時 2026-08-27 17:26:56
合計ジャッジ時間 4,586 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# 包除原理、ビット全探索
# Algo X Math ID068

N = int(input())
abc = list(map(int, input().split()))
K = 3

from math import gcd

ans = 0 
for bit in range(1<<K):
    if bit == 0:
        continue
    count = 0
    LCM = 1
    for shift in range(K):
        if bit>>shift & 1 == 1:
            count += 1
            LCM = LCM*abc[shift]//gcd(LCM, abc[shift])
    if count%2 == 1:
        ans += N//LCM
    else:
        ans -= N//LCM
    #print(bin(bit), count, LCM, N//LCM, ans)

print(ans)
0