#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define vi std::vector<ll>
#define si set<ll>
#define INF 100000000
#define pb push_back
#define mod 1000000007
ll solve(){
ll n,a,b;
cin >> n >> a >>b;
si t;
for (int i = 0; i < n; ++i)
{
ll l,r;
cin >> l >> r;
for (int j = l; j <= r; ++j){
t.insert(j);
}
}
set<pair <ll, ll> > ans;
ll sum = 0;
for(auto c: t){
ll x = (c/b);
x += c;
x %= a;
ll y= c%b;
cout << c << " ";
if(ans.count(make_pair(x,y))){
cout << x << " " << y << " alr present\n";
}
else cout << x << " " << y << "\n";
ans.insert(make_pair(x,y));
sum ++;
}
cout << "\n";
// for(auto x: ans){
// cout << x.first << " " << x.second << "\n";
// }
cout << ans.size();
return 0;
}
ll solve2(){
ll n,a,b;
cin >> n >> a >>b;
si t;
ll q = b+1;
ll z = a;
ll hc = __gcd(q,z);
q/= hc;
z/= hc;
ll p = z*b;
// cout << p;
for (int i = 0; i < n; ++i)
{
ll l,r;
cin >> l >> r;
for (int j = l; j <= r; ++j){
t.insert(j%p);
}
}
cout << t.size();
// set<pair <ll, ll> > ans;
// ll sum = 0;
// for(auto c: t){
// ll x = (c/b);
// x += c;
// x %= a;
// ll y= c%b;
// cout << c << " ";
// if(ans.count(make_pair(x,y))){
// cout << x << " " << y << " alr present\n";
// }
// else cout << x << " " << y << "\n";
// ans.insert(make_pair(x,y));
// sum ++;
// }
// cout << "\n";
// // for(auto x: ans){
// // cout << x.first << " " << x.second << "\n";
// // }
// cout << ans.size();
return 0;
}
int main(){
fastio;
ll t = 1;
// freopen("div7.in","r",stdin);
// freopen("div7.out","w",stdout);
// cin >> t;
for (int i = 0; i < t; ++i){
// cout << "Case #" << i+1 << ": ";
solve2();
cout << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5087 ms |
303984 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
3755 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5065 ms |
45568 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5042 ms |
58288 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5042 ms |
58288 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5042 ms |
58288 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
3717 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5087 ms |
303984 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |