제출 #216341

#제출 시각아이디문제언어결과실행 시간메모리
216341usachevd0이상한 기계 (APIO19_strange_device)C++14
0 / 100
5080 ms524292 KiB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

void debug_out()
{
    cerr << endl;
}

template<typename T1, typename... T2> void debug_out(T1 A, T2... B)
{
    cerr << ' ' << A;
    debug_out(B...);
}

#ifdef DEBUG
    #define time(...) 42
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 42
#endif

template<typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template<typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

signed main()
{
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    ll A, B;
    cin >> n >> A >> B;
    ll M;
    if (B % A == A - 1)
        M = B;
    else
    {
        ld temp = A * (ld)B;
        if (temp > 1000000000000000100LL)
        {
            ll sum = 0;
            while (n--)
            {
                ll l, r;
                cin >> l >> r;
                sum += r - l + 1;
            }
            cout << sum << '\n';
            exit(0);
        }
        M = A * B;
    }
    set<ll> rem;
    while (n--)
    {
        ll l, r;
        cin >> l >> r;
        for (ll x = l; x <= r; ++x)
            rem.insert(x % M);
    }
    cout << rem.size() << '\n';

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...