Advertisement
xerpi

niggest rises

Nov 3rd, 2013
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int raw_digits(int x);
  5. int central_digit(int x);
  6.  
  7. int main() {
  8.     int n;
  9.     cin >> n;
  10.     int i = 0;
  11.     bool winner = false;
  12.     bool first = true;
  13.     int x, m;
  14.     while ((cin >> x) and (i < 2*n) and (!winner)) {
  15.         ++i;
  16.         if (x > 9 and raw_digits(x)%2 == 0) winner = true;
  17.         else if (first) {
  18.             first = false;
  19.             m = central_digit(x);
  20.         }
  21.         if (m != central_digit(x)) winner = true;
  22.     }
  23.     if (!winner) cout << "=" << endl;
  24.     else if (i%2 == 0) cout << "A" << endl;
  25.     else cout << "B" << endl;
  26. }
  27.  
  28. int raw_digits(int x) {
  29.     int i = 0;
  30.     while (x > 0) {
  31.         x /= 10;
  32.         ++i;
  33.     }
  34.     return i;
  35. }
  36.  
  37. int central_digit(int x) {
  38.     if (x < 10) return x;
  39.     int i = 1;
  40.     int n = raw_digits(x)/2 + 1;
  41.     while (i < n) {
  42.         x /= 10;
  43.         ++i;
  44.     }
  45.     x %= 10;
  46.     return x;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement