![](https://img-blog.csdnimg.cn/2020120615544426.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
算法竞赛
退役ACM选手做过的一些题目
The_Moth
独向昭潭制恶龙。
展开
-
hdu6602 Fansblog(威尔逊定理+大整数判断素数+质数密度+逆元)
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=6608题目描述输入输出样例Sample Input11000000007Sample Output328400734题意给定一个大质数P(1e9与1e14之间),找出小于P的最大质数Q,求Q!mod P的值。思路先了解一个事实,P与Q之间的差值并不大...原创 2019-08-11 19:34:35 · 200 阅读 · 0 评论 -
【nowcoder_挑战赛31】克洛涅的多项式(构造)
链接:https://ac.nowcoder.com/acm/contest/880/B来源:牛客网题目描述克洛涅修女来到了这所孤儿院。Sister 很快就和大家打成一片,开始了捉迷藏的游戏。Sister 今天藏起来了一个 n 次的多项式 F(x)。同时,作为线索,她给出了一个 m 次的多项式 G(x) 。这里 m < n 。她又给出了一个有恰好 n 个不同元素的集合 S...原创 2019-07-20 21:50:21 · 141 阅读 · 0 评论 -
Codeforces Round #549 (Div. 2) ——D.The Beatles
链接:http://codeforces.com/contest/1143/problem/D内容:Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going throughn⋅kn⋅kcities. The cities are numerated from11to...原创 2019-04-05 16:16:14 · 295 阅读 · 0 评论 -
Wannafly挑战赛29 B——白井黑子
链接:https://ac.nowcoder.com/acm/contest/271/B来源:牛客网题目描述:kuroko 作为常盘台唯一的空间系能力者,在每年例行的能力测试中可绝对不能让 misaka 失望哦,但是由于她的等级只是 level 4「大能力者」,在能力测试中会遇到不少困难。kuroko 是一个凡事都会尽力的好女孩,所以请你帮她算出她最多能完成多少测试吧对于空间系能力...原创 2019-03-08 15:46:50 · 267 阅读 · 0 评论 -
洛谷P1357 花园(状态压缩+矩阵快速幂)
题目链接https://www.luogu.org/problem/P1357题目描述小L有一座环形花园,沿花园的顺时针方向,他把各个花圃编号为1~N(2<=N<=10^15)。他的环形花园每天都会换一个新花样,但他的花园都不外乎一个规则,任意相邻M(2<=M<=5,M<=N)个花圃中有不超过K(1<=K<M)个C形的花圃,其余花圃均为P形的花...原创 2019-08-01 18:10:09 · 336 阅读 · 0 评论 -
Educational Codeforces Round 61———F.Clear the String
链接:http://codeforces.com/contest/1132/problem/F内容:You are given a stringssof lengthnnconsisting of lowercase Latin letters. You may apply some operations to this string: in one operation you c...原创 2019-03-14 23:09:55 · 158 阅读 · 0 评论 -
洛谷P1297 [国家集训队]单选错位
链接:https://www.luogu.org/problemnew/show/P1297题目描述:gx和lc去参加noip初赛,其中有一种题型叫单项选择题,顾名思义,只有一个选项是正确答案。试卷上共有n道单选题,第i道单选题有ai个选项,这ai个选项编号是1,2,3,…,ai,每个选项成为正确答案的概率都是相等的。lc采取的策略是每道题目随机写上1-ai的某个数作为答案选项,他用不了多...原创 2019-04-13 13:33:04 · 251 阅读 · 0 评论 -
[SHOI2017]分手是祝愿
链接:https://ac.nowcoder.com/acm/problem/20437来源:牛客网题目:B 君在玩一个游戏,这个游戏由 n 个灯和 n 个开关组成,给定这 n 个灯的初始状态,下标为从 1 到 n 的正整数。每个灯有两个状态亮和灭,我们用 1 来表示这个灯是亮的,用 0 表示这个灯是灭的,游戏 的目标是使所有灯都灭掉。但是当操作第 i 个开关时,所有编号为 i 的约数...原创 2019-03-30 23:33:52 · 190 阅读 · 0 评论 -
hdu 3507 Print Article(斜率优化)
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=3507关于斜率优化我理解的不太透彻,讲也讲不清楚。这里只是整理一下模板,见谅见谅。代码#include <bits/stdc++.h>#define maxn 500010#define ll long longusing namespace std;ll n,m,c...原创 2019-09-27 20:38:27 · 151 阅读 · 0 评论 -
Educational Codeforces Round 74 (Rated for Div. 2) D. AB-string(逆向思维)
题目链接https://codeforces.com/contest/1238/problem/D题目描述The string t1t2…tkis good if each letter of this string belongs to at least one palindrome of lengthgreaterthan1.A palindrome is a stri...原创 2019-10-10 20:12:56 · 203 阅读 · 0 评论 -
Codeforces Round #591 D. Sequence Sorting(逆向思维)
题目链接https://codeforces.com/contest/1241/problem/D题目描述You are given a sequence a1,a2,…,an, consisting of integers.You can apply the following operation to this sequence: choose some integerxa...原创 2019-10-10 20:00:00 · 219 阅读 · 0 评论 -
CodeForces 877E Danil and a Part-time Job (dfs序+线段树)
K - Danil and a Part-time Job CodeForces - 877E Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a light switcher....原创 2017-12-21 09:17:01 · 301 阅读 · 0 评论 -
Educational Codeforces Round 70 (Rated for Div. 2) C. You Are Given a WASD-string...(线段树)
题目链接http://codeforces.com/contest/1202/problem/C题目描述You have a stringss— a sequence of commands for your toy robot. The robot is placed in some cell of arectangulargrid. He can perform four ...原创 2019-09-01 00:58:50 · 348 阅读 · 0 评论 -
hdu6638 Snowy Smile(线段树+最大子段和)
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=6638题目Problem DescriptionThere arenpirate chests buried in Byteland, labeled by1,2,…,n. Thei-th chest's location is(xi,yi), and its value is...原创 2019-08-24 10:24:35 · 234 阅读 · 0 评论 -
hdu6602 Longest Subarray(线段树)
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=6602题目描述输入输出样例Sample Input7 4 22 1 4 1 4 3 2Sample Output4题意给定一个数组,数的范围是[1,C],给定K,让你找一个最长的区间使得区间内任意一个出现的数在该区间内的数量都大于等于K 。...原创 2019-08-11 19:06:40 · 155 阅读 · 0 评论 -
E. Nastya Hasn't Written a Legend
来源:https://www.cnblogs.com/pkgunboat/p/10527569.html题目:http://codeforces.com/contest/1136/problem/E题意:有一个数组a和一个数组k,数组a一直保持一个性质:a[i + 1] >= a[i] + k[i]。有两种操作:1,给某个元素加上x,但是加上之后要保持数组a的性质。比如a[i]加...转载 2019-03-20 22:26:29 · 320 阅读 · 0 评论 -
hdu6667 Roundgod and Milk Tea(Hall定理)
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=6667题目描述Problem DescriptionRoundgod is a famous milk tea lover at Nanjing University second to none. This year, he plans to conduct a milk tea fes...原创 2019-08-29 00:14:53 · 245 阅读 · 0 评论 -
ICPC2019 沈阳网络赛 K.Guanguan's Happy water(高斯消元+逆元+矩阵快速幂)
题目链接https://nanti.jisuanke.com/t/41411思路怎么说呢,这题就是让你先解模线性方程组,然后用矩阵快速幂算数列前n项和。虽说跟模板题很接近但也有160多行代码,我觉得写起来还是很繁琐的,调试起来也不简单。这里不多说了,就把这题当作高斯消元模板记录一下吧。代码#include <bits/stdc++.h>#define ll lo...原创 2019-09-16 23:17:52 · 283 阅读 · 0 评论 -
codeforces1027D. Number Of Permutations(排列组合+容斥原理)
题目链接http://codeforces.com/contest/1207/problem/D题目描述You are given a sequence ofnpairs of integers:(a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is sorted in non-descending orde...原创 2019-08-30 14:50:08 · 392 阅读 · 0 评论 -
hdu6620 Just an Old Puzzle
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=6620题目描述ou are given a 4 × 4 grid, which consists of 15 number cells and an empty cell.All numbers are unique and ranged from 1 to 15.In this boar...原创 2019-08-15 23:09:18 · 149 阅读 · 0 评论 -
洛谷P1641 [SCOI2010]生成字符串(排列组合+逆元)
原文链接https://www.luogu.org/blog/user29936/solution-p1641题目链接https://www.luogu.org/problem/P1641题目描述lxhgww最近接到了一个生成字符串的任务,任务需要他把n个1和m个0组成字符串,但是任务还要求在组成的字符串中,在任意的前k个字符中,1的个数不能少于0的个数。现在lxhgww想要知...转载 2019-08-03 17:47:37 · 271 阅读 · 0 评论 -
Codeforces Round #339 (Div. 1) A. Peter and Snow Blower(点到线段距离)
题目链接https://codeforces.com/contest/613/problem/A思路求多边形绕一定点扫过的圆环面积。外圆半径r2为多边形顶点到定点的最长距离。内圆半径r1为多边形的边到定点的最短距离。代码#include <bits/stdc++.h>#define ll long longusing namespace std;cons...原创 2019-11-01 10:39:14 · 113 阅读 · 0 评论 -
洛谷P2742 圈奶牛Fencing the Cows(凸包模板)
题目链接https://www.luogu.org/problem/P2742代码#include <bits/stdc++.h>#define ll long longusing namespace std;const ll maxn=1e4+10;int inf=1e9;void read(int &x){ int f=1;x=0;char ...转载 2019-10-30 19:49:01 · 305 阅读 · 0 评论 -
Educational Codeforces Round 46 (Rated for Div. 2) E.We Need More Bosses(双连通分量+缩点)
题目链接https://codeforces.com/contest/1000/problem/E题意给出一张图,设两点s,t,则可在s,t两点间的必经之边(去掉这条边,s、t不可达)上放置怪物,找到s、t,使得它可放置最多的怪物。输出可放置的最多的怪物。题解利用tarjan求出该图的所有边-双连通分量,缩点,形成一棵树,求出树的直径,得到答案。代码#include ...原创 2019-11-11 22:36:07 · 326 阅读 · 0 评论 -
Codeforces Round #650 (Div. 3) E. Necklace Assembly(枚举+二分)
题目链接:https://codeforces.com/contest/1367/problem/E思路: 不难想象,这是一道跟循环节有关的问题。k是necklace的周期,这个说法等价于存在k的因数d,使得d是整条necklace的周期。这样,问题转化如下:构造循环节长度为d的necklace,使得其长度最大。代码:#include <iostream>#include <cstring>#include <cstdio>#include ..原创 2020-07-09 23:36:05 · 178 阅读 · 0 评论 -
Codeforces Round #582 (Div. 3) D2. Equalizing by Division (hard version)(思维+枚举暴力)
题目链接https://codeforces.com/contest/1213/problem/D2题目描述You are given an arrayaconsisting ofnintegers. In one move you can choose anyaiaiand divide it by2rounding down (in other words, in ...原创 2019-10-04 18:21:55 · 169 阅读 · 0 评论