题目传送门

 /*
题意:问是否能用质量为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. HDU 5280 Senior&#39;s Array

    Senior's Array Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) T ...

  2. curl 发送json请求

    curl 发送json请求 这个是在cmd环境下的输入:注意{\"userName\":\"helo\",\"id\":1}中间不能有空格 ...

  3. Navicat for MySQL出现#1045 错误怎么办

    #1045 - Access denied for user 'root'@'localhost' (using password: NO)这是因为你连接的时候没有密码或者密码没改对导致的.如下图所示 ...

  4. 【转载】SOAP协议介绍

    SOAP是用在分散或分布的环境中交换信息的简单的协议,它是一个基于XML的协议,包括三个部分:封装定义了一个描述消息中包含什么内容以及如何处理它们的框架,编码规则用于表示应用程序定义的数据类型的实例, ...

  5. jQuery选择器特殊字符与属性空格问题

    一.选择器中含有特殊符号的注意事项 1.选择器中含有“.”.“#”.“(”或“]”等特殊字符 根据W3C的规定,属性值中是不能含有这些特殊字符的,但在实际项目中偶尔会遇到表达式中含有“#”和“.”等特 ...

  6. IDEA失效的解决办法

    1.根据下图进行操作即可解决

  7. 自己写的Android端HttpUtil工具类

    package com.sxt.jcjd.util; import java.io.IOException; import java.io.UnsupportedEncodingException; ...

  8. 定时邮件 已经稳定运行10天+ 从局域网linux到外网邮箱

  9. 并不对劲的bzoj2820:p2257:YY的GCD

    题目大意 \(t\)(\(t\leq10^4\))组数据,给定\(n,m\)(\(n,m\leq10^6\))求 \[\sum_{x=1}^{n}\sum_{y=1}^{m}[gcd(x,y)=1]\ ...

  10. gdb core调试

    原文链接 http://blog.163.com/lanka83/blog/static/32637615200801793020182/http://blog.csdn.net/taina2008/ ...