Submission #171489

#TimeUsernameProblemLanguageResultExecution timeMemory
171489losmi247Strange Device (APIO19_strange_device)C++14
0 / 100
5103 ms405904 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <ll,ll> p; const int N = 1e6+56; const ll inf = 4e18; ll n,a,b,l[N],r[N]; void prvi(){ map <p,bool> mapa; for(int i = 1; i <= n; i++){ for(int t = l[i]; t <= r[i]; t++){ ll x = (t+t/b)%a,y = t%b; mapa[p(x,y)] = 1; } } cout << mapa.size() << endl; } void drugi(){ ll period = a*b; ll x = l[1],y = r[1]; if(x-y+1 >= period){ cout << period << endl; } else{ cout << (x-y+1)%period << endl; } } void treci(){ } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> a >> b; ll s = 0; for(int i = 1; i <= n; i++){ cin >> l[i] >> r[i]; s += r[i]-l[i]+1; } /*for(int t = 0; t <= 300; t++){ ll x = (t+t/b)%a,y = t%b; cout << "za t = " << t << " " << x << " " << y << endl; }*/ if(s <= 1000000){ prvi(); return 0; } if(n == 1){ drugi(); return 0; } if(a <= b/inf && a*b <= 1000000){ treci(); return 0; } }
#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...