結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2023-02-27 22:10:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 42 ms / 1,000 ms |
コード長 | 503 bytes |
コンパイル時間 | 493 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 52,224 KB |
最終ジャッジ日時 | 2024-09-15 03:52:42 |
合計ジャッジ時間 | 3,260 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
# 包除原理、ビット全探索 # 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)