Vanya and Scales CodeForces - 552C (思维)】的更多相关文章

大意: $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…
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: 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 &…
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…
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…
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…
题目链接: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…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard 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 weight…
题目大概说有101个质量w0.w1.w2.....w100的砝码,和一个质量m的物品,问能否在天平两边放物品和砝码使其平衡. 哎,怎么没想到..注意到w0.w1.w2.....w100—— 把m转化成w进制数,枚举每一位: 如果第i位是0那OK: 如果是1那就要把砝码wi放在天平另一边抵消: 如果是w-1那就要把砝码wi放到天平同一边,使其变为0并进位,这时第i+1位的权+1: 而如果是其他情况,那么肯定不能平衡了. #include<cstdio> #include<cstring&g…