Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<set>
  3. #include<vector>
  4. #include<iostream>
  5. #include<algorithm>
  6. #include<cmath>
  7. #include<queue>
  8. #include<random>
  9. #include<ctime>
  10. #define x first
  11. #define y second
  12. #define all(x) x.begin(), x.end()
  13. #define pb push_back
  14. #define mp make_pair
  15. using namespace std;
  16. #define int long long
  17. void mini(int n,int l,int r){
  18. int ans = 1;
  19. int cnt = 1;
  20. while(cnt < l){
  21. cnt++;
  22. ans += (1 << (cnt - 1));
  23. }
  24. // cout << ans << endl;
  25. cout << ans + (n - cnt) << ' ';
  26. }
  27. void maxi(int n,int l,int r){
  28. int cnt = 1;
  29. int ans = 1;
  30. while(cnt < r){
  31. if(cnt == n){
  32. break;
  33. }
  34. cnt++;
  35. ans += (1 << (cnt - 1));
  36. }
  37. ans += (n - cnt) * (1 << (cnt - 1));
  38. cout << ans;
  39. }
  40. signed main(){
  41. int n,l,r;
  42. cin >> n >> l >> r;
  43. mini(n,l,r);
  44. maxi(n,l,r);
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement