Vanya and Scales(思维)】的更多相关文章

Vanya and Scales time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some integer not less tha…
C. Vanya and Scales Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some integer not less than 2(exactly one weight of each nominal value). Vanya wonders whether he can weight an item with mass m usi…
Vanya and Scales Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 552C Description Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some…
C. Vanya and Scales time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some integer not less…
C. Vanya and Scales Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/problem/C Description Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some integer not less than 2 (…
题目传送门 /* 题意:问是否能用质量为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 &…
题目链接:http://codeforces.com/problemset/problem/552/C 题目大意:有101个砝码重量为w^0,w^1,....,w^100和一个重量为m的物体,问能否在天平两边放物品和砝码使其平衡.解题思路:将m化为w进制的数,接下来从低到高遍历没一位:如果第i位是0那OK:如果是1那就要把砝码wi放在天平另一边抵消:如果是w-1那就要把砝码wi放到天平同一边,使其变为0并进位,这时第i+1位的权+1:而如果是其他情况,那么肯定不能平衡了. 代码: #includ…
大意: $101$个砝码, 重$w^0,w^1,...,w^{100}$, 求能否称出重量$m$. w<=3时显然可以称出所有重量, 否则可以暴力双端搜索. #include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #incl…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some integer not less than 2(exactly one…
这个题的意思就是给出一个数m.以及一个以1为首元素.w为比例常数的等比数列,数列长度为101,数列中每一个数字最多仅仅能用一次.问是否存在xa+wb+--=wc+wd+--+we+m. 非常显然,换句话说就是问,是否存在m=wa+wb+--+wf-wc-wd----we.再进行化简就能够得到.是在问,是否存在m=((((wh±1)wi±1)±1)wj±1)wk--. 那么非常显然可以进行搜索,比方说用广搜,每次当前的m±1中若有因子w就所有约掉,然后丢到队列中,否则就不用管,仅仅要队列中可以出现…