제출 #976783

#제출 시각아이디문제언어결과실행 시간메모리
976783AIF_is_carving이상한 기계 (APIO19_strange_device)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; void solve(){ set<pair<ll, ll>> s; ll n, A, B; cin>>n>>A>>B; if(n>1){ for(int i=0; i<n; i++){ ll x, y; cin>>x>>y; for(ll t = x; t<=y; t++){ ll p = (t+(t/B))%A; ll q = t%B; s.insert({p,q}); } } cout<<s.size()<<"\n"; } else{ ll n, A, B; cin>>n>>A>>B; ll x, y; cin>>x>>y; ll X = A/(gcd(B+1, A)); ll t; int powX=0, powB=0; ll xxx = X; while(xxx>0){ xxx/=2; powX+=1; } xxx=B; while(xxx>0){ xxx/=2; powB+=1; } if(powB+powX>61) t=2e18; else t = B*X; cout<<min<ll>(y-x+1, t)<<"\n"; } return; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t=1; //cin>>t; while(t--){ solve(); } 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...