結果
| 問題 | No.546 オンリー・ワン | 
| コンテスト | |
| ユーザー |  T1610 | 
| 提出日時 | 2019-03-23 01:55:00 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 1,217 bytes | 
| コンパイル時間 | 1,551 ms | 
| コンパイル使用メモリ | 170,156 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-19 11:18:01 | 
| 合計ジャッジ時間 | 2,247 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 | 
ソースコード
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
ll calc(ll N, ll x) {
    return N / x;
}
ll calc(ll l, ll r, ll x) {
    if(l == 1) return calc(r, x);
    else return calc(r, x) - calc(l-1, x);
}
ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}
int main(){
    ll N, L, H;
    cin >> N >> L >> H;
    vl c(N);
    rep(i, N) cin >> c[i];
    ll ans = 0LL;
    REP(mask, 1, 1<<N) {
        ll x = 1LL;
        int cnt = __builtin_popcount(mask);
        rep(i, N) if(mask & (1<<i)) x = lcm(x, c[i]);
        if(cnt&1) ans += calc(L, H, x) * cnt;
        else ans -= calc(L, H, x) * cnt;
        // cout << bitset<6>(mask) << " " << x << " " << calc(L, H, x) << endl;
    }
    cout << ans << endl;
    return 0;
}
            
            
            
        