Advertisement
erek1e

IOI '05 P5 - Rectangle Game (Standard I/O)

Jul 9th, 2023
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int x, y;
  7.     while (cin >> x && cin >> y && x != -1) {
  8.         int a = min(x, y), b = max(x, y);
  9.         int loss = a; // a, a
  10.         while (2*loss+1 <= b) loss = 2*loss+1;
  11.         // move from a, b to a, loss
  12.         cout << (a == x ? 'H' : 'V') << ' ' << loss << endl;
  13.     }
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement