Submission #1031711

#TimeUsernameProblemLanguageResultExecution timeMemory
1031711Halym2007Strange Device (APIO19_strange_device)C++17
10 / 100
5087 ms524288 KiB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define sz size()
#define ll long long
#define pii pair <ll, ll> 
const int N = 1e4 + 5;

set <pii> s;

int main () {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//	freopen ("input.txt", "r", stdin);
	int n;
	ll a, b;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; ++i) {
		ll l, r;
		cin >> l >> r;
		for (ll j = l; j <= r; ++j) {
//			return cout << j << " "
			ll a1 = (j + (j / b)) % a, b1 = j % b;
//			cout << "j-lar ->" << j << " " << a1 << " " << b1 << "\n";
			s.insert ({a1, b1});
		}
	}
	cout << (int)s.sz;
}
#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...