CF1039D You Are Given a Tree 容易发现,当 \(k\) 不断增大时,答案不断减小,且 \(k\) 的答案不超过 \(\lfloor\frac {n}{k}\rfloor\) ,因此不同的答案个数是 \(\sqrt n\) 级别的,可以用一种类似整体二分的方式求解. 对于一个 \(k\) ,从叶子节点贪心向上匹配即可得到答案. 点击查看代码 #include<bits/stdc++.h> using namespace std; int n; int ver[2000…
F. Souvenirs 题目连接: http://codeforces.com/contest/765/problem/F Description Artsem is on vacation and wants to buy souvenirs for his two teammates. There are n souvenir shops along the street. In i-th shop Artsem can buy one souvenir for ai dollars, a…
Problem A. Neverending competitions 题目大意 一个团队有多个比赛,每次去比赛都会先订机票去比赛地点,然后再订机票返回.给出\(n\)个含有起止地点的购票记录(不按时间顺序),判断这个团队是否返回. 题解 竞速题 因为每次比赛都必定是一去一返 所以当订票记录个数为偶数的时候一定在家中,否则一定在比赛. Code a = input() if a % 2 == 0: print 'home' else: print 'contest' Problem B. Cod…
When the winter holiday comes, a lot of people will have a trip. Generally, there are a lot of souvenirs to sell, and sometimes the travelers will buy some ones with pleasure. Not only can they give the souvenirs to their friends and families as gift…