Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define pb push_back
- #define ll long long
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(0);
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int a,b,l,r;
- cin >> a >> b >> l >> r;
- l--;
- r--;
- int sz=r-l+1;
- if (b>=a){
- cout << r << " " << l << endl;
- l=l%(a+b);
- r=l+sz-1;
- if (sz>a+b){
- cout << a+1 << endl;
- return 0;
- }
- if (l<a && sz==a+b) {
- cout << a << endl;
- return 0;
- }
- if (l>=a && sz==a+b) {
- cout << a+1 << endl;
- return 0;
- }
- if (r<=a+b){
- cout << max(sz-l,1) << endl;
- return 0;
- }
- if (r>a+b){
- cout << min(a+1,r-a-b+1) << endl;
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement