Codeforces Round #275 (Div. 1)A. Diverse Permutation Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/482/problem/A Description Permutation p is an ordered set of integers p1,   p2,   ...,   pn, consisting of n distinct posi…
LINK:CF R 654 div2 前言:F题是一个线段树分类讨论的题目 比赛的时候没看 赛后感觉没什么意思 所以咕掉了. 记事:第一次笼统的写一场比赛的题目 可能是我这场比赛打的太差了 题目不难 赛后轻而易举的解决 赛时可能是状态的问题吧. A.Magical Sticks 容易发现不论奇偶构成的数字最优解一定为n 然后偶数答案显然为n/2 奇数可以多构成一对 n/2+1. code //#include<bits\stdc++.h> #include<iostream> #i…
比赛链接:https://codeforces.com/contest/1371 A. Magical Sticks 题意 有 $n$ 根小棍,长度从 $1$ 到 $n$,每次可以将两根小棍连接起来,问最多有多少根小棍长度相同. 题解 如:1 2 3 4 5,相同长度最多的情况为 1+4  2+3  5 . 即 $(1 + n - 1), (2 + n - 2), \dots$,所以答案为 $\lfloor \frac{n - 1}{2} \rfloor + 1$ . 代码 #include <…
题意:你需要在长度从\(1\)~\(k\),宽度无限的网格图中造图形(每个点四周必须连通),问最多能造出多少种不同的图形. 题解:感觉没什么好说的,就是画图找规律,如果\(r\ge n\)的话(即没有任何空间限制),那么就是1+1+....+n-1,否则就被网格图限制了,这时的方案数只能是1+2+....+r. 代码: int t; ll n,r; int main() { ios::sync_with_stdio(false);cin.tie(0); cin>>t; while(t--){…
题意:构造一个\(n\)x\(n\)只含\(0\)和\(k\)个\(1\)的矩阵,统计每一行每一列\(1\)的sum,然后构造一个权值最大行和最小行的差的平方加权值最大列和最小列的差的平方的最小和(\(f(A)=(max(R)-min(R))^2+(max(C)-min(C))^2\)的最小值). 题解:假如\(k\ mod\ n=0\)的话,那么最小值一定是0,否则一定是2,直接上图吧. ​ 1.k%n=0: ​ 2.k%n!=0: 这样的话,规律应该显而易见了吧,我们沿着对角线构造,然后取余…
题意:有\(a\)个蛋糕,\(b\)个巧克力,第一类人有\(n\)个,总是吃多的东西(若\(a>b\),吃蛋糕,否则吃巧克力),第二类人有\(m\)个,总是吃少的,可以随便调整这两类人吃的顺序,问是否能让所有人都吃到东西. 题解:首先\(a+b\ge n+m\),这个条件是一定要成立的, 然后我们最优先的方法一定是让第二类人先吃,因为假如让第一类人先吃的话,他们会先吃目前最多的食物,然后如果吃到目前的食物与另一种数目相等的话,就要去吃另一种,这样,当第二类人吃的时候,因为他们只能吃少的那种食物,…
C. K-special Tables 题目连接: http://www.codeforces.com/contest/625/problem/C Description 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 an outstanding competitiv…
D. The table 题目连接: http://www.codeforces.com/contest/226/problem/D Description Harry Potter has a difficult homework. Given a rectangular table, consisting of n × m cells. Each cell of the table contains the integer. Harry knows how to use two spells…
C. Harmony Analysis 题目连接: http://www.codeforces.com/contest/610/problem/C Description The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil…
D. Lazy Student Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/606/problem/D Description Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a gr…