D. My pretty girl Noora     In Pavlopolis University where Noora studies it was decided to hold beauty contest "Miss Pavlopolis University". Let's describe the process of choosing the most beautiful girl in the university in more detail. The con…
传送门 题意 对于n个女孩,每次分成x人/组,每组比较次数为\(\frac{x(x+1)}{2}\),直到剩余1人 计算\[\sum_{i=l}^{r}t^{i-l}f(i)\],其中f(i)代表i个女孩的最少比较数 分析 难度在于如何计算f(i),f(i)每次除的是素数,详情见题解 那么我们对于每一个素数i,直接计算\(f[i]=\frac{x(x+1)}{2}\) 非素数,枚举能被i整除的第一个素数j,\(f[i]=f[i/j]+i*(j-1)/2\) -end- trick 代码 #inc…
Codeforces Round #422 (Div. 2) Table of Contents Codeforces Round #422 (Div. 2)Problem A. I'm bored with lifeProblem B.Crossword solvingProblem C. Hacker, pack your bags! Problem A. I'm bored with life A. I'm bored with life Holidays have finished. T…
[题目链接]:http://codeforces.com/contest/822/problem/D [题意] 有n个人参加选美比赛; 要求把这n个人分成若干个相同大小的组; 每个组内的人数是相同的; 然后每个组内的人,两两比较; 每个组得出最美的人; 然后每个组中最美的人再重复上述步骤; 直到只剩一个人; 问你如何选定每个阶段的分组; 使得比较的次数最少; [题解] 只考虑一轮的情况; 设x是分组后每个组的人数; 然后一共有n个人; 则这一轮比较的次数就为 nx∗x∗(x−1)2 ->n∗(x…
[题目链接]:http://codeforces.com/contest/822/problem/C [题意] 有n个旅行计划, 每个旅行计划以开始日期li,结束日期ri,以及花费金钱costi描述; 让你在这n个旅行计划中选出两个计划; 要求这两个计划的日期没有相交的部分; 且这两个日期的总时间长度恰好为x; 让你求最小花费 [题解] 先把每个计划按照左端点第一优先级,右端点第二优先级升序排序; 然后定义一个dp[x]数组,表示在前i个计划中,时长为x,且右端点的位置< a[i].l的一个旅行…
[题目链接]:http://codeforces.com/contest/822/problem/B [题意] 让你用s去匹配t,问你最少需要修改s中的多少个字符; 才能在t中匹配到s; [题解] O(n2)的暴力搞就好; [Number Of WA] 1 [反思] 一开始判断的时候脑抽了; 写成只有s[1]==t[1]的时候才枚举; hack点是: 很多人两重for循环,没有给j层循环加限制; 直接两层循环1..n和1..m [完整代码] #include <bits/stdc++.h> u…
[题目链接]:http://codeforces.com/contest/822/problem/A [题意] 让你求a!和b!的gcd min(a,b)<=12 [题解] 哪个小就输出那个数的阶乘 [Number Of WA] 0 [反思] [完整代码] #include <bits/stdc++.h> using namespace std; #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define L…
题意:给你两个串s,p,问你把s分开顺序不变,能不能用最多k段合成p. 题解:dp[i][j]表示s到了前i项,用了j段的最多能合成p的前缀是哪里,那么转移就是两种,\(dp[i+1][j]=dp[i][j],dp[i+lcp][j+1]=dp[i][j]+lcp\),这里的lcp是dp[i][j]和i的lcp,然后sa预处理一下st表就行了 //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pragma GCC optimize(4)…
E. Liar     The first semester ended. You know, after the end of the first semester the holidays begin. On holidays Noora decided to return to Vičkopolis. As a modest souvenir for Leha, she brought a sausage of length m from Pavlopolis. Everyone know…
C. Hacker, pack your bags!     It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hac…