Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int x, y, sum = 0;
  6. int temp = 0;
  7. cin >> x >> y;
  8. if (x > y) {
  9. if (x % 2 == 0)
  10. {
  11. temp = x / 2;
  12. sum += temp + temp / 2 - 1;
  13. }
  14. else if (x % 2 == 1) {
  15. temp = x / 2 + 1;
  16. sum += temp + temp / 2 - 1;
  17. }
  18. }
  19. else if (y > x)
  20. {
  21. if( y % 2 == 0)
  22. {
  23. temp = y / 2;
  24. sum += temp + temp / 2 - 1;
  25. }
  26. else if (y % 2 == 1) {
  27. temp = y / 2 + 1;
  28. sum += temp + temp / 2 - 1;
  29. }
  30. }
  31. if (x == y) {
  32. if (x == 2)
  33. cout << 1;
  34. if (x == 3)
  35. cout << 2;
  36. if (x == 1)
  37. cout << 1;
  38. else if (x % 2 == 0)
  39. {
  40. temp = x / 2;
  41. sum = temp + temp - 1;
  42.  
  43. }
  44. else if (x % 2 == 1) {
  45. temp = x / 2 + 1;
  46. sum = temp + temp - 1;
  47. }
  48. }
  49. cout << sum;
  50. system("pause");
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement