Submission #727056

#TimeUsernameProblemLanguageResultExecution timeMemory
727056SanguineChameleonStrange Device (APIO19_strange_device)C++17
10 / 100
5086 ms524288 KiB
#include <bits/stdc++.h> using namespace std; void just_do_it(); int main() { #ifdef KAMIRULEZ freopen("kamirulez.inp", "r", stdin); freopen("kamirulez.out", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); just_do_it(); return 0; } const int maxN = 1e6 + 20; const long long inf = 1e18L + 20; long long L[maxN]; long long R[maxN]; void just_do_it() { int N; long long A, B; cin >> N >> A >> B; for (int i = 0; i < N; i++) { cin >> L[i] >> R[i]; } if (A > inf / B) { long long res = 0; for (int i = 0; i < N; i++) { res += R[i] - L[i] + 1; } cout << res; return; } set<pair<long long, long long>> S; for (int i = 0; i < N; i++) { for (long long j = L[i]; j <= R[i]; j++) { S.insert({(j + (j / B)) % A, j % B}); } } cout << S.size(); }
#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...