题目传送门

 /*
题意:问是否能用质量为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. spring mvc 整理

    spring mvc 整理

  2. Office WORD如何输入长下划线

    选中一段文字,点击下划线按钮,可以添加下划线   同样,选中一段空格,点下划线,也可以添加下划线    

  3. easyUI 验证控件应用、自己定义、扩展验证 手机号码或电话话码格式

    easyUI 验证控件应用.自己定义.扩展验证 手机号码或电话话码格式 在API中   发现给的demo 中没有这个验证,所以就研究了下. 相关介绍省略,直接上代码吧! watermark/2/tex ...

  4. JS 省市区三级联动

    JS 省市区三级联动: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ ...

  5. windows内存管理的机制以及优缺点

    分页存储管理基本思想:用户程序的地址空间被划分成若干固定大小的区域,称为“页”,相应地,内存空间分成若干个物理块,页和块的大小相等.可将用户程序的任一页放在内存的任一块中,实现了离散分配. 分段存储管 ...

  6. hdu 2059 龟兔赛跑 (dp)

    /* 把起点和终点比作加油站,那总共同拥有n+2个加油站了, 每次都求出从第0个到第j个加油站(j<i)分别在加满油的情况下到第i个加油站的最短时间dp[i], 终于的dp[n+1]就是最优解了 ...

  7. C中使用memset

    int i; cout<<memset(&i,1,sizeof(int))<<endl; 输出结果是16843009,而不是填充的1111 1111,为什么呢? 因为m ...

  8. JDK各版本内容和新特性

    JDK各版本内容和新特性 - yanlzhl - 博客园 https://www.cnblogs.com/yanlzhl/articles/5694470.html    版本JDK1.0:1995年 ...

  9. fastjson将json字符串中时间戳转化为日期

    开发中,调用接口,往往会返回一个json字符串.对于json中的时间戳应该如何转为日期对象呢? 定义一个DateValueFilter类,这个类实现了fastjson中ValueFilter接口.其作 ...

  10. caution

    做好需求更改的准备,提高代码的扩展性和可维护性:预留出修改bug和需求的时间:对需求理解透彻再开始写代码:代码不要写死,防止需求变动.