제출 #1217868

#제출 시각아이디문제언어결과실행 시간메모리
1217868veplsnx이상한 기계 (APIO19_strange_device)C++20
10 / 100
172 ms32324 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define u128 unsigned __int128
#define i128 __int128
#define len(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define ff first
#define ss second

const ll inf = 9e18;
const int iinf = 2e9;
const int N = 1e5;
const ll MOD = 1e9 + 7;

void solution(){
    int n; ll a, b; cin >> n >> a >> b;
    ll s = 0, mx_len = 0;
    vector<ll> l(n), r(n);
    for (int i = 0; i < n; ++i){
        cin >> l[i] >> r[i];
        s += (r[i] - l[i] + 1);
        mx_len = max(mx_len, r[i] - l[i] + 1);
    }
    if (s <= (int)1e6){
        set<pair<ll, ll>> st;
        for (int i = 0; i < n; ++i){
            for (ll t = l[i]; t <= r[i]; ++t){
                ll x = (t + (t / b)) % a;
                ll y = t % b;
                st.insert({x, y});
            }
        }
        cout << len(st);
    }
}

signed main(/* Kurmankul Nurislam */){
    //freopen("fcolor.in", "r", stdin);
    //freopen("fcolor.out", "w", stdout);
    cin.tie(nullptr) -> sync_with_stdio(false);
    int t = 1;
    //cin >> t;
    while (t--){
        solution();
        //cout << '\n';
    }
}
#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...