이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ft first
#define sd second
#define pb push_back
#define nl "\n"
#define int ll
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1000100;
int n, a, b;
void solve() {
cin >> n >> a >> b;
int S = 0;
map<int, int> mp;
int R;
for (int i = 0; i < n; i++) {
int l, r;
cin >> l >> r;
R = r;
S += (r - l + 1);
for (int j = l; j <= r; j++) {
mp[j] = 1;
}
}
if (S <= 1e6) {
for (auto j : mp) {
if (j.sd == 0) continue;
int t = j.ft;
int k = 0;
while(t + b * (k + 1) <= R) {
k++;
if (mp.find(t + b * k) != mp.end() && (b + 1) * k % a == 0) {
S--;
mp[t + b * k] = 0;
}
}
}
cout << S << nl;
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
while(T--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |