結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
|
提出日時 | 2020-04-13 22:19:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 602 bytes |
コンパイル時間 | 817 ms |
コンパイル使用メモリ | 73,208 KB |
最終ジャッジ日時 | 2025-01-09 18:14:56 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <iostream>#include <numeric>#include <vector>using lint = long long;void solve() {lint n;std::cin >> n;std::vector<lint> xs(3);for (auto& x : xs) std::cin >> x;lint ans = 0;for (int b = 1; b < (1 << 3); ++b) {lint l = 1;for (int i = 0; i < 3; ++i) {if ((b >> i) & 1) l = std::lcm(l, xs[i]);}ans += n / l * (__builtin_popcountll(b) % 2 == 1 ? 1 : -1);}std::cout << ans << std::endl;}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);solve();return 0;}