Codeforces 810 C. Do you want a date?】的更多相关文章

C. Do you want a date? time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output   Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he imme…
[题目链接]:http://codeforces.com/contest/810/problem/C [题意] 给你一个集合,它包含a[1],a[2]..a[n]这n个整数 让你求出这个集合的所有子集a的f(a)和 这里的f(a)=集合a中最大和最小元素的差; [题解] 朴素的想法是; 将数组a升序排; 枚举最后的集合中最大和最小的元素是a[i]和a[j](i< j); 则f值是a[j]-a[i]的集合有2^(j-i-1)个; 即a[i+1]..a[j-1]这些元素选和不选-. 然后答案+=2(…
题目链接:http://codeforces.com/contest/810/problem/D 题意:两个人玩一场游戏要猜出Noora选的f种菜的任意两种.一个人猜点另一个人回答 TAK如果 ,(x,y是猜的数,a表示Noora 选的菜中离x最近的,b是离y最近的,菜种是1-n个数.)否则就回答NIE. 题解:这题比较特殊,输入只需要n,k然后根据我们的输出题目作出反馈. 怎么确保能找到答案.我们可以将(1-n)分成两份(1-mid)(mid+1-r),显然要猜的数肯定是在这两个区间内. 然后…
B. Summer sell-off   time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time j…
A. Straight «A»   time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Noora is a student of one famous high school. It's her final year in school — she is going to study in university next ye…
codeforces 810 D. Glad to see you! http://codeforces.com/contest/810/problem/D 题意 大小为k的集合,元素的范围都在[1,n],每次可以询问(x,y),如果min|x-a|<=min|y-b| a,b∈S,交互库返回”TAK",否则返回“NIE”. 分析 怎么确保能找到答案.我们可以将(1-n)分成两份(1-mid)(mid+1-r),显然要猜的数肯定是在这两个区间内. 然后怎么判断我们可以找mid和mid+1两…
题目链接:http://codeforces.com/gym/101158/attachments /* * @Author: lyucheng * @Date: 2017-10-21 12:20:04 * @Last Modified by: lyucheng * @Last Modified time: 2017-10-21 21:12:12 */ /* * 题意:给你两个字符串,让你求最长子串,子串在两个字符串中都出现(长度相同,出现的字母次数相同就行) * * 思路:枚举每个长度的字符串…
C. Do you want a date? time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immedi…
codeforces.com/contest/810/problem/C [题意] 给定一个集合A,求 , 输入: [思路] 基数为n的集合有2^n-1个非空子集. 首先n个数要从小到大排序,枚举最后的集合中最大和最小的元素是a[i]和a[j](i< j); 则f值是a[j]-a[i]的集合有2^(j-i-1)个; 然后答案+=(a[j]−a[i])*2^(j-i-1); 这样时间复杂度是O(n^2). 我们可以把各项组合一下,把2^i提取出来. 比如考虑系数为 2^1的 必然是 a[3]-a[…
题目链接:http://codeforces.com/problemset/problem/515/A 题目意思:问能否从 (0, 0) 出发,恰好走 s 步,到达该位置(a, b). 首先容易知道,最少的步数为 |a| + |b|,最长就是——当然是无限啦(乱兜圈子就行).然后就有一点点带着个人感觉来做了= =,第六感确实不错的,呵呵,证明就有待考究了. 如果 |a| + |b| 跟 s 的奇偶性相同就有解,否则无解.当然前提是满足 s 至少要比最少的步数大! #include <iostre…