/** * @brief Codeforces Round #280 (div. 2) d * @file d.cpp * @author mianma * @created 2014/12/02 14:38 * @edited 2014/12/02 14:38 * @type math brute binary_search * @note */#include <fstream> #include <iostream> #include <cstring> #include <algorithm> #include <iomanip> #include <cstdlib>using namespace std ; #define &NBSP;MAX (A, b) ((a) > (b) ? (a) : (b)) #define Min (a, b) ((a) > (b) ? (b) : (a)) #define &NBSP;ABS (a) (a) > 0 ? (a) : (0 - (a) )) #define &NBSP;CLR (VEC) memset (vec, 0, sizeof (VEC)) #ifdef DEBUGifstream in;ofstream out;#define cin in#define cout out#else#define cin cin#define cout cout# Endiftypedef long long int ll;int x, y, n;ll lft, rht, mid, a;int main (void) { ios_base::sync_with_stdio (0); #ifdef DEBUG cin.open ("./in", ios::in); cout.open ("./out", ios::o UT); #endif CIN >> n >> x >> y; while (n--) { cin >> a; lft = 0, rht = max (x, y) * (1E9) + 1; while (Lft < rht) { mid = ((rht - lft) >>1) + lft; if (Mid/x + mid/y < a) lft = mid + 1; else rht = mid; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP, #ifdef DEBUG COUT << lft < < "<->" << rht << "\ n"; #endif if ( 0 == rht%x & & 0 == rht%y) { cout << "both\n"; }else if (0 == rht% x) {&NBSP;&NBSP;&NBSP;&Nbsp; cout << "Vova\n"; }else{ cout << "vanya\n"; } } return 0;}
Codeforces Round #280 (Div. 2) d