Codeforces Round #280 (Div. 2) D

Source: Internet
Author: User

Topic:

D. Vanya and computer Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard Inputoutputstandard Output

Vanya and his friend Vova play a computer game where they need to destroyNMonsters to pass a level. Vanya ' s character performs attack with frequencyxHits per second and Vova ' s character performs attack with frequencyyHits per second. Each character spends fixed time to raise a weapon and then he hits (the time to raise the weapon is1?/? x Seconds for the first character and1?/? y Seconds for the second one). TheI-th Monster dies after he receives ai Hits.

Vanya and Vova wonder who makes the last hits on each monster. If Vanya and Vova make the last hits at the same time, we assume that both of them has made the last hit.

Input

The first line contains three integersN,x,y(1?≤? n? ≤?105 ,1?≤? x,? y? ≤?106 )-the number of monsters, the frequency of Vanya ' s and Vova ' s attack, correspondingly.

NextNLines contain integers ai (1?≤? a i? ≤?109 )-the number of hits needed do destroy theI-th Monster.

Output

Print n lines. In the i-th line print word "Vanya", if the last hits on the i-th monster is performed by Vanya , "Vova", if Vova performed the last hit, or "Both", if Both boys performed it at the same time.

Sample Test (s) input
4 3 21234
Output
Vanyavovavanyaboth
Input
2 1 112
Output
Bothboth
Note

In The first sample Vanya makes the first hit at Time 1?/?2 , Vanya makes ' third ' at Time 

The second sample Vanya and Vova make the first and second hits simultaneously at time 1.


Analysis: The feeling of the topic description is not very clear. Sad ... Read it for a long time.

The first reaction, the data range is very large appearance. Careful analysis found that the positive integer seconds must be both, and in integer seconds is the cycle of the festival.

Put the first second in the Order of the table, followed by the MoD solved. The limit condition is also 1e6,1s enough.


#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <vector > #include <queue> #include <stack> #include <cassert> #include <algorithm> #include < cmath> #include <set> #include <limits> #include <map>using namespace std; #define MIN (A, B) ((a) < (b)? (a): (b) #define MAX (A, B) ((a) > (b)? (a): (b) #define F (i, n) for (int (i) =0; (i) < (n), + + (i)) #define REP (I, S, T) for (int (i) = (s);(i) <= (t), + + (i) #define UR EP (I, S, T) for (int (i) = (s);(i) >= (t);-(i)) #define REPOK (I, S, T, O) for (int (i) = (s);(i) <= (t) && (o); + + (i)) # Define MEM0 (Addr) memset ((addr), 0, sizeof ((addr))) #define PI 3.1415926535897932384626433832795#define Half_pi 1.5707963267948966192313216916398#define MAXN 1000010; #define MAXM 10000#define MOD 1000000007typedef long LL; Const double maxdouble = Numeric_limits<double>::max (); const double EPS = 1e-10;const int INF = 0x7fffffff;string a[ 10000100];inT main () {int n;    Double x, y;    int cnt1,cnt2,cnt;        while (CIN >> n >> x>> y) {cnt = Cnt1 = Cnt2 = 1; while (cnt1/x <= 1&&cnt2/y <= 1) {if (cnt1/x < cnt2/y) {a[cnt                + +] = "Vanya";            ++cnt1;                }else if (cnt1/x > cnt2/y) {a[cnt++] = "Vova";            ++cnt2;                }else {a[cnt++] = "Both";                a[cnt++] = "Both";            cnt1++,cnt2++;            }} while (n--) {int x;            scanf ("%d", &x);            if (x (cnt-1) = = 0) cout<<a[cnt-1]<<endl;        else cout<<a[x% (cnt-1)]<<endl; }} return 0;}


Codeforces Round #280 (Div. 2) D

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.