이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef int64_t llo;
#define a first
#define b second
#define endl "\n"
llo gcd(llo kk,llo ll){
if(ll==0){
return kk;
}
return gcd(ll,kk%ll);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
llo n,a,b;
cin>>n>>a>>b;
llo x;
pair<llo,llo> it;
x=b;
x*=(a/gcd(a,b+1));
/* if((b+1)%a==0){
x=b;
}
else{
x=a*b;
}*/
llo aa,bb;
set<pair<llo,llo>> ac;
for(llo i=0;i<n;i++){
cin>>aa>>bb;
aa%=x;
bb%=x;
if(bb<aa){
ac.insert(mp(aa,x-1));
ac.insert(mp(0,bb));
}
else{
ac.insert(mp(aa,bb));
}
}
vector<pair<llo,llo>> prev;
for(auto cc:ac){
if(prev.size()==0){
prev.pb(cc);
}
else{
if(cc.a>prev.back().b){
prev.pb(cc);
}
else{
prev[prev.size()-1].b=max(prev[prev.size()-1].b,cc.b);
}
}
}
llo tot=0;
for(llo i=0;i<prev.size();i++){
tot+=prev[i].b-prev[i].a+1;
}
cout<<tot<<endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp: In function 'int main()':
strange_device.cpp:63:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(llo i=0;i<prev.size();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... |