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