Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define pb push_back
  3. #define ll long long
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8. ios_base::sync_with_stdio(0);
  9. freopen("input.txt", "r", stdin);
  10. freopen("output.txt", "w", stdout);
  11. int a,b,l,r;
  12. cin >> a >> b >> l >> r;
  13. l--;
  14. r--;
  15. int sz=r-l+1;
  16. if (b>=a){
  17. cout << r << " " << l << endl;
  18. l=l%(a+b);
  19. r=l+sz-1;
  20. if (sz>a+b){
  21. cout << a+1 << endl;
  22. return 0;
  23. }
  24. if (l<a && sz==a+b) {
  25. cout << a << endl;
  26. return 0;
  27. }
  28. if (l>=a && sz==a+b) {
  29. cout << a+1 << endl;
  30. return 0;
  31. }
  32. if (r<=a+b){
  33. cout << max(sz-l,1) << endl;
  34. return 0;
  35. }
  36. if (r>a+b){
  37. cout << min(a+1,r-a-b+1) << endl;
  38. return 0;
  39. }
  40. }
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement