time limit per test2 seconds memory limit per test512 megabytes inputstandard input outputstandard output Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solv…
题目链接 可以发现 十进制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> #…
题目链接: D. Friends and Subsequences time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Toda…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output When Xellos was doing a practice course in university, he once had to measure the intensity of an effect that slowly approached equilibrium. A g…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the meth…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph - somet…
[题目链接]:http://codeforces.com/contest/766/problem/E [题意] 定义树上任意两点之间的距离为这条简单路径上经过的点; 那些点上的权值的所有异或; 求任意两点之间的距离和; [题解] 权值最大为1e6 所以每个点的权值的二进制形式最多20位左右; 则我们可以对权值的二进制形式的每一位独立考虑; 我们枚举第i位; 并且在计算的时候只考虑这第i位; 可以做树形dp; 算出穿过当前这个节点的路径(并且以其为lca->最高点) 异或和的二进制形式在第i为上权…
[题目链接]:http://codeforces.com/problemset/problem/733/F [题意] 给你n个点m条边; 让你从中选出n-1条边; 形成一个生成树; (即让n个点都联通); 然后,你有S的预算; 每次可以选择一条边i,然后花费ci的预算,把这条边的权值递减1; (边一开始的权值为wi); 问你最后的最小生成树是多少; [题解] /* 肯定是找某一条边一直减(ci最小的那一个,因为代价最小,又都是减少1); 把m条边按照w升序排; 做个最小生成树; 把最小生成树里面…
[题目链接]:http://codeforces.com/contest/799/problem/D [题意] 给你长方形的两条边h,w; 你每次可以从n个数字中选出一个数字x; 然后把h或w乘上x; 直到能够把一个长为a宽为b的长方形装下为止; 问你最小的数字选择次数; [题解] 把所给的n个数字从大到小排; 显然同样是选一个数字,选大的数字肯定比较优; 问题只是要让哪一条边乘上它; 这里可以知道 如果全都是2的话 最多需要34个数字; 因为log2(100000)≈17 然后两条边都最多需要…
[题目链接]:http://codeforces.com/problemset/problem/22/C [题意] 给你n个点; 要求你构造一个含m条边的无向图; 使得任意两点之间都联通; 同时,要求这张图; 在删掉第x个节点之后,会有一些点之间变成不联通的; (两点之间最多连一条边) [题解] 把v和某一个点x连在一起; 然后除了这两个点之外的其他n-2个点; 先每一个点都和v连一条边; 保证联通; 然后如果边数还有剩余; 就在那剩余的n-2个点之间一直连边,直到练成一个团(n-2个点的完全图…