Violence/Conversion Codeforces Round #308 (Div. 2) C. Vanya and Scales

Source: Internet
Author: User

Topic Portal

1 /*2 Test Instructions: Ask if you can use the mass of w^0,w^1,..., w^100 weights each weigh m, weights left or on the right3 Brute Force/conversion: Suppose it can be called, denoted by W, each of which is 0,1,w-1. W-1 means that weights and items are put together, and the simulation determines whether each bit is OK4 Detailed Explanation:http://blog.csdn.net/u011265346/article/details/465563615 Summary: The game did not go into the system to think, even the sample does not know what is going on. Not Chinese: (6 */7#include <cstdio>8#include <cmath>9#include <cstring>Ten#include <algorithm> One using namespacestd; A  - intMainvoid)//codeforces Round #308 (Div. 2) C. Vanya and Scales - { the     //freopen ("c.in", "R", stdin); -  -     intW, N; -      while(SCANF ("%d%d", &w, &n) = =2) +     { -         if(n = =3) {puts ("YES");Continue;} +  A          while(n) at         { -             intTMP = n%W; -             if(TMP <=1) n/=W; -             Else if(TMP = = W-1) n = n/w +1; -             Else{Puts ("NO"); Break;} -         } in  -         if(!n) puts ("YES"); to     } +  -     return 0; the}

Violence/Conversion Codeforces Round #308 (Div. 2) C. Vanya and Scales

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.