Codeforces Round #280 (Div. 2) d

Source: Internet
Author: User

/** *  @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

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.