暴力/进制转换 Codeforces Round #308 (Div. 2) C. Vanya and Scales
/*
题意:问是否能用质量为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的更多相关文章
- 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 ...
- 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 ...
- 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table
题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...
- 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books
题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #308 (Div. 2)
A. Vanya and Table Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows ...
- 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 ...
随机推荐
- 【Nginx】请求上下文
上下文与全异步web服务器的关系 请求上下文指在一个请求的处理过程中,把一些关键的信息保存下来的类似struct这样的结构体.每个http模块都可以有自己的上下文结构体,一般都是在刚开始处理请求时在内 ...
- Hexo搭建个人blog
Hexo搭建 现在只想说心累... 前几天看了几个牛人的blog,感觉他们的风格很舒服,然后就发现了Hexo这个好东西!激动的想马上自己也弄一个,昨天晚上开始看资料特别是:潘柏信写了两篇 HEXO搭建 ...
- CF 234 C Weather(粗暴方法)
C. Color Stripe time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- iOS 获取手机 唯一标识
存贮在keychainQuery 可以统计用户使用情况 -(void)gatherMessage{ //采集用户设备信息 NSUserDefaults *userDefaults=[NSUserDef ...
- 【SICP练习】149 练习4.5
练习4-5 原文 Exercise 4.5. Scheme allows an additional syntax for cond clauses, ( => ). If evaluates ...
- ImageLoader实现图片异步载入
ImageLoader是一个广泛使用的图片库,在向网络请求图片时.使用imageView和smartView常会产生outofmemory错误,这时ImageLoader能够起到非常大的作用.主要有例 ...
- iOS开发中正则式的使用
iOS开发中正则式的使用 第一:常规的使用方式 NSString *str = @"abcded111093212qweqw"; //找到内部一个即可 NSString *patt ...
- Oracle改动字段类型
因为需求变动.现要将一个类型NUMBER(8,2)的字段类型改为 char. 大体思路例如以下: 将要更改类型的字段名改名以备份.然后加入一个与要更改类型的字段名同名的字段(原字段已经改名 ...
- mac for smartSVN9 (8,9)破解方法 附smartSvn_keygen工具图文
mac for smartSVN9 (8,9)破解方法 附smartSvn_keygen工具 工具文件下载: http://files.cnblogs.com/files/xueshanshan/s ...
- android中init.rc文件的解析问题
init.rc中文件里会通过import /init.${ro.hardware}.rc文件,这个ro.hardware应该是某个详细的属性.而这个ro.hardware赋值应该是在Init进程中赋值 ...