http://codeforces.com/contest/746/problem/D 题意:有n杯茶,a杯绿茶,b杯红茶,问怎么摆放才可以让不超过k杯茶连续摆放,如果不能就输出NO. 思路:首先,设x = min(a,b),y = max(a,b),然后如果(y + x)/(x + 1) > k,那么就输出NO.即把 y 平均分成 x + 1 份,向上取整.然后开始搞... 搞的时候我直接对于 y 每一次都输出最大的份数了,导致后面的 x 过多,还自以为是平均的. 所以应该处理一下,如果有剩余…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags,…
题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制数字,求出其长len,当len为奇数时,第一位为1,后面的位数如果都为0,则输出len,如果有一个不为0,则输出len+1: 当len为偶数时,则输出len.(之所以这样输出是因为题目给定4的次幂是从0开始的) #include<iostream> #include<string> #…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given n numbers a1, a2, -, an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We wan…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and th…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output The process of mammoth's genome decoding in Berland comes to its end! One of the few remaining tasks is to restore unrecognized nucleotides in a…
[题目链接]:http://codeforces.com/problemset/problem/757/D [题意] 给你一个01串; 让你分割这个01串; 要求2切..n+1切; 对于每一种切法 所切成的各个部分的二进制,转成十进制之后;假设里面最大的数为m; 问1..m这些数字都出现的切法有多少种; [题解] 可以算一下对于1个75位的数字来说; 最多只可能连续出现 从 1..20 你可以算一下1..20这20个数字的二进制形式恰好占74个; 不能再多一个数字了,因为21的二进制形式的长度肯…
[题目链接]:http://codeforces.com/problemset/problem/757/E [题意] 给你q个询问; 每个询问包含r和n; 让你输出f[r][n]; 这里f[0][n]是n分解成两个数u,v的乘积的个数; 这里u和v互质; 而f[r][n]当r>0时,有个递推式; [题解] 那个递推式等价于 即n的所有因子x的f[r][x]的和; 这里需要知道; f[0][n]=2n的不同质因子个数 且容易得到 当a和b互质的时候,f[0][a*b]=f[0][a]*f[0][b…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become a…
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…