题目传送门

 /*
题意:问是否能用质量为w^0,w^1,...,w^100的砝码各1个称出重量m,砝码放左边或在右边
暴力/进制转换:假设可以称出,用w进制表示,每一位是0,1,w-1。w-1表示砝码与物品放在一起,模拟判断每位是否ok
详细解释:http://blog.csdn.net/u011265346/article/details/46556361
总结:比赛时压根没往进制去想,连样例也不知道是怎么回事。。中文不行啊:(
*/
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std; int main(void) //Codeforces Round #308 (Div. 2) C. Vanya and Scales
{
// freopen ("C.in", "r", stdin); int w, n;
while (scanf ("%d%d", &w, &n) == )
{
if (n == ) {puts ("YES"); continue;} while (n)
{
int tmp = n % w;
if (tmp <= ) n /= w;
else if (tmp == w - ) n = n / w + ;
else {puts ("NO"); break;}
} if (!n) puts ("YES");
} return ;
}

暴力/进制转换 Codeforces Round #308 (Div. 2) C. Vanya and Scales的更多相关文章

  1. Codeforces Round #308 (Div. 2) C. Vanya and Scales dfs

    C. Vanya and Scales Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/p ...

  2. Codeforces Round #308 (Div. 2)----C. Vanya and Scales

    C. Vanya and Scales time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

    题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...

  4. 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books

    题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...

  5. Codeforces Round #308 (Div. 2) A. Vanya and Table 暴力

    A. Vanya and Table Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/pr ...

  6. Codeforces Round #308 (Div. 2) D. Vanya and Triangles 水题

    D. Vanya and Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55 ...

  7. Codeforces Round #308 (Div. 2)B. Vanya and Books 数学

    B. Vanya and Books Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/pr ...

  8. Codeforces Round #308 (Div. 2)

    A. Vanya and Table   Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows ...

  9. Codeforces Round #355 (Div. 2) D. Vanya and Treasure 分治暴力

    D. Vanya and Treasure 题目连接: http://www.codeforces.com/contest/677/problem/D Description Vanya is in ...

随机推荐

  1. [转]图解eclipse 查看原始类出现The jar file rt.jar has no source attachment

    原文:http://blog.csdn.net/u011514810/article/details/53196371 ---------------------------------------- ...

  2. SQL 连接(JOIN)

    SQL 连接(JOIN) SQL join 用于把来自两个或多个表的行结合起来. SQL JOIN SQL JOIN 子句用于把来自两个或多个表的行结合起来,基于这些表之间的共同字段. 最常见的 JO ...

  3. poj1904 二分图匹配+强连通分量

    http://poj.org/problem?id=1904 Description Once upon a time there lived a king and he had N sons. An ...

  4. css 滤镜之Gradient

      CreateTime--2017年12月26日11:09:14 Author:Marydon ie滤镜特效之Gradient 作用: 用于设置渐变背景色 使用条件: IE9及以下版本不支持属性ba ...

  5. 【Mongodb教程 第一课 补加课1 】windows7 下安装mongodb 开启关闭服务

    mongodb在2.2版本开始就不支持windows xp了(我想现在用xp的应该也是带着情怀的一部分人吧,我只是一个工匠而已),windows下server8 R2,64位,32位,只是32位只支持 ...

  6. 接口测试工具--Fiddler 的使用

    代码部分 Rules -> Customize Rules  打开Fiddler ScriptEditor,这里可以通过修改脚本中某些方法( OnBeforeRequest(oSession: ...

  7. CodeForces - 344D Alternating Current (模拟题)

    id=46667" style="color:blue; text-decoration:none">CodeForces - 344D id=46667" ...

  8. Visual Studio Code 常用插件

    这里记录在Visual Studio Code中,我经常用到的插件. C#这个就不必说了,想用VIsual Studio Code调试和编辑C#代码,必须要装这个插件.东西还好,就是每次安装和更新插件 ...

  9. S2SH的集成(Struts2,Spring,Hibernate)----青软S2SH(笔记)

  10. HR-部门内部调动报表

    *&---------------------------------------------------------------------* *& Report  ZHRPA038 ...