Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int x, y, sum = 0;
- int temp = 0;
- cin >> x >> y;
- if (x > y) {
- if (x % 2 == 0)
- {
- temp = x / 2;
- sum += temp + temp / 2 - 1;
- }
- else if (x % 2 == 1) {
- temp = x / 2 + 1;
- sum += temp + temp / 2 - 1;
- }
- }
- else if (y > x)
- {
- if( y % 2 == 0)
- {
- temp = y / 2;
- sum += temp + temp / 2 - 1;
- }
- else if (y % 2 == 1) {
- temp = y / 2 + 1;
- sum += temp + temp / 2 - 1;
- }
- }
- if (x == y) {
- if (x == 2)
- cout << 1;
- if (x == 3)
- cout << 2;
- if (x == 1)
- cout << 1;
- else if (x % 2 == 0)
- {
- temp = x / 2;
- sum = temp + temp - 1;
- }
- else if (x % 2 == 1) {
- temp = x / 2 + 1;
- sum = temp + temp - 1;
- }
- }
- cout << sum;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement