結果

問題 No.546 オンリー・ワン
ユーザー kura197kura197
提出日時 2021-06-20 11:09:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,064 bytes
コンパイル時間 2,047 ms
コンパイル使用メモリ 201,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 01:24:15
合計ジャッジ時間 2,871 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:23:43: 警告: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   23 | void dfs(ll idx, ll num, ll val, ll& ans, auto& C){
      |                                           ^~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define MOD(a, m) ((a % m + m) % m)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll N, L, H;

ll lcd(ll a, ll b){
    ll g = gcd(a, b);
    return g * a/g * b/g;
}

void dfs(ll idx, ll num, ll val, ll& ans, auto& C){
    if(idx == N){
        if(num == 0) return;
        ll x = H/val - (L-1)/val;
        if(num % 2) ans += num*x;
        else ans -= num*x;
        return;
    }

    dfs(idx+1, num, val, ans, C);
    dfs(idx+1, num+1, lcd(val, C[idx]), ans, C);
}

int main(){
    cin >> N >> L >> H;
    vector<ll> C(N);
    for(auto& c : C)
        cin >> c;

    ll ans = 0;

    dfs(0, 0, 1, ans, C);

    cout << ans << endl;

    return 0;
}
0