結果
| 問題 |
No.546 オンリー・ワン
|
| コンテスト | |
| ユーザー |
はまやんはまやん
|
| 提出日時 | 2017-07-14 23:13:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 1,951 bytes |
| コンパイル時間 | 1,766 ms |
| コンパイル使用メモリ | 170,760 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-07 23:31:25 |
| 合計ジャッジ時間 | 2,565 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
ll countMultiple(ll L, ll R, ll div) {
if (R % div == 0) {
if (L % div == 0) return R / div - L / div + 1;
else return R / div - L / div;
} else {
if (L % div == 0) return R / div - L / div + 1;
else return R / div - L / div;
}
}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
/*---------------------------------------------------------------------------------------------------
∧_∧
∧_∧ (´<_` ) Welcome to My Coding Space!
( ´_ゝ`) / ⌒i
/ \ | |
/ / ̄ ̄ ̄ ̄/ |
__(__ニつ/ _/ .| .|____
\/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/
int N;
ll L, H;
ll C[11];
ll cn[11];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N >> L >> H;
rep(i, 0, N) cin >> C[i];
ll ans = 0;
rep(i, 0, N) {
vector<ll> CC;
ll d = 0;
rep(j, 0, N) if (i != j) CC.push_back(C[j]);
rep(mask, 0, 1<<(N - 1)) {
ll lc = C[i];
int cnt = 0;
rep(j, 0, N - 1) if (mask & (1 << j)) lc = lcm(lc, CC[j]), cnt++;
ll c = countMultiple(L, H, lc);
if (cnt % 2 == 0) d += c;
else d -= c;
}
ans += d;
}
cout << ans << endl;
}
はまやんはまやん