# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
252087 | jeqcho | Strange Device (APIO19_strange_device) | C++17 | 587 ms | 16760 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define N 1000005
using namespace std;
inline ll Get() {ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}while('0'<=ch&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}return x*f;}
int n;
ll A,B,len;
struct node {
ll l,r;
bool operator <(const node &a)const {
if(l!=a.l) return l<a.l;
return r<a.r;
}
}s[N<<1];
ll gcd(ll a,ll b) {return !b?a:gcd(b,a%b);}
int main() {
n=Get(),A=Get(),B=Get();
for(int i=1;i<=n;i++) s[i].l=Get(),s[i].r=Get();
ll g=gcd(A,B+1);
ll ans=0;
if((long double)A/g*B>1e18) {
for(int i=1;i<=n;i++) ans+=s[i].r-s[i].l+1;
} else {
ll len=A/g*B;
int tot=n;
for(int i=1;i<=n;i++) {
# | 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... |