제출 #1060408

#제출 시각아이디문제언어결과실행 시간메모리
1060408epneq이상한 기계 (APIO19_strange_device)C++14
10 / 100
5025 ms524288 KiB
#include <iostream>
#include <set>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

ll calculate_x(ll t, ll A, ll B) {
    return (t + t / B) % A;
}

void process_interval(ll l, ll r, ll A, ll B, set<pll>& distinct_pairs) {
    for (ll t = l; t <= r; ++t) {
        ll y = t % B;
        ll x = calculate_x(t, A, B);
        distinct_pairs.insert({x, y});
    }
}

int main() {
    int n;
    ll A, B;
    cin >> n >> A >> B;

    set<pll> distinct_pairs;

    for (int i = 0; i < n; ++i) {
        ll li, ri;
        cin >> li >> ri;
        process_interval(li, ri, A, B, distinct_pairs);
    }

    cout << distinct_pairs.size() << endl;

    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…