結果
問題 | No.546 オンリー・ワン |
ユーザー |
![]() |
提出日時 | 2020-06-14 19:26:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 858 bytes |
コンパイル時間 | 1,784 ms |
コンパイル使用メモリ | 166,356 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 17:25:43 |
合計ジャッジ時間 | 2,099 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
ソースコード
#include <bits/stdc++.h>#define debug(x) cerr << #x << ": " << x << endl#define debugArray(x, n) \for (long long hoge = 0; (hoge) < (n); ++(hoge)) \cerr << #x << "[" << hoge << "]: " << x[hoge] << endlusing namespace std;long long lcm(long long x, long long y) { return x * y / __gcd(x, y); }signed main() {cin.tie(0);ios::sync_with_stdio(false);long long N, L, H;cin >> N >> L >> H;int C[N];for (int i = 0; i < N; i++) cin >> C[i];long long ans = 0;for (int bit = 0; bit < (1 << N); bit++) {int cnt = __builtin_popcount(bit);long long mul = 1;for (int i = 0; i < N; i++)if ((bit >> i) & 1) mul = lcm(mul, C[i]);long long tmp = H / mul - (L - 1) / mul;if (cnt & 1)ans += cnt * tmp;elseans -= cnt * tmp;}cout << ans << endl;return 0;}