# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
145581 | mhy908 | 이상한 기계 (APIO19_strange_device) | C++14 | 739 ms | 18896 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n;
LL a, b;
bool iscalc=true;
LL gcd(LL x, LL y)
{
if(!y)return x;
return gcd(y, x%y);
}
vector<pll> vc;
int main()
{
scanf("%d %lld %lld", &n, &a, &b);
LL temp=a/gcd(a, b+1);
LL pv=0;
LL ans=0;
if(log10(temp)+log10(b)>=18.1)iscalc=false;
else temp*=b;
for(int i=1; i<=n; i++){
LL x, y;
scanf("%lld %lld", &x, &y);
if(!iscalc){
vc.push_back({x, y});
continue;
}
LL xx=x%temp;
LL yy=y%temp;
if(x==y)vc.push_back({xx, xx});
else{
if(x/temp==y/temp)vc.push_back({xx, yy});
else if(x/temp+1==y/temp&&xx>=yy)vc.push_back({xx, temp-1}), vc.push_back({0, yy});
else vc.push_back({0, temp-1});
}
}
sort(vc.begin(), vc.end());
for(int i=0; i<vc.size(); i++){
LL e=vc[i].first, r=vc[i].second;
ans+=(max(pv, vc[i].first)>vc[i].second?0:vc[i].second-max(pv, vc[i].first)+1);
pv=max(vc[i].second+1, pv);
}
printf("%lld", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |