이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 3e18;
ll gcd(ll a, ll b){
return __gcd(a, b);
}
ll get(ll a, ll b){
ll c = (a / gcd(a, b + 1)), hi = inf / b;
if(c > hi){
c = inf;
}
else{
c *= b;
}
return c;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t = 1;
while(t--){
ll n, a, b, i, l, r;
cin >> n >> a >> b;
ll x = get(a, b);
vector<array<ll, 2>> v;
bool ok = 1;
for(i = 1; i <= n; i++){
cin >> l >> r;
ok &= ((r - l + 1) >= x);
l %= x;
r %= x;
if(r < l){
v.push_back({l, x - 1});
v.push_back({0, r});
}
else{
v.push_back({l, r});
}
}
if(ok){
cout << x << "\n";
return 0;
}
sort(v.begin(), v.end());
ll s = 0, hi = -1;
for(i = 0; i < v.size(); i++){
if(v[i][0] > hi){
s += (v[i][1] - v[i][0] + 1);
hi = v[i][1];
}
else
{
s+=max(0ll,v[i][1]-hi);
hi=max(hi,v[i][1]);
}
}
cout << s << "\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp: In function 'int main()':
strange_device.cpp:49:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(i = 0; i < v.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... |