规律题(找啊、找啊、找不着啊)
RevolIA
这个作者很懒,什么都没留下…
展开
-
经典约瑟夫问题(快速求每一次淘汰)
n个人,每k个淘汰。就是经典约瑟夫,没有任何改动。若问最后一人,有个O(n)的dp,若问每一次淘汰的人数,那么我这里有个O(n*(logk)*logk)的算法。考虑树状数组优化。记数组A为这n个人是否被淘汰的标记数组,用树状数组记录前缀和。那么,每次可以二分以快速找到应该淘汰的下表,二分里套树状数组,所以带两个logpos记录当前位置,容易知道,pos将数组分为两块,若右边的个数小于等于k,说明位于,否则在上。对k处理一下防止超出范围。来个标准的lower_bound即可。代码如下原创 2021-01-16 14:57:38 · 336 阅读 · 1 评论 -
最大公约数
问题 D: 最大公约数时间限制:1Sec内存限制:128 MB[提交] [状态]题目描述给定n个正整数,a_1,a_2,…,a_n,求最少删去几个数,使得删去后这些数的最大公约数比原先的所有数的最大公约数大。输入第一行一个整数n,第二行n个正整数,a_1,a_2,…,a_n。输出一个数,表示最少删去的个数,若无论怎么删都不会比原来的大,输出-1。样例输入...原创 2020-04-08 13:08:12 · 810 阅读 · 0 评论 -
Sum Equals Xor(我果然还是不太会dp)
You are given a positive integer L in base two. How many pairs of non-negative integers (a,b) satisfy the following conditions?·a+b≤L·a+b=a XOR bSince there can be extremely many such pairs, print ...原创 2020-02-02 20:34:07 · 310 阅读 · 0 评论 -
Envious Exponents
4897: Envious Exponents时间限制: 1 Sec 内存限制: 128 MB提交: 320 解决: 52[提交] [状态] [讨论版] [命题人:admin]题目描述Alice and Bob have an integer N. Alice and Bob are not happy with their integer. Last night they w...原创 2018-08-25 11:44:48 · 157 阅读 · 0 评论 -
YJJ's Salesman
YJJ's SalesmanTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1085 Accepted Submission(s): 371 Problem DescriptionYJJ is a salesman w...原创 2018-08-26 20:43:39 · 357 阅读 · 0 评论 -
Parallel Lines
8839: Parallel Lines时间限制: 10 Sec 内存限制: 128 MB提交: 126 解决: 24[提交] [状态] [讨论版] [命题人:admin]题目描述Given an even number of distinct planar points, consider coupling all of the points into pairs.All ...原创 2018-08-29 19:36:15 · 434 阅读 · 0 评论 -
ACM-ICPC 2018 南京赛区网络预赛-J_sum
A square-free integer is an integer which is indivisible by any square number except 11. For example, 6 = 2 \cdot 36=2⋅3 is square-free, but 12 = 2^2 \cdot 312=22⋅3 is not, because 2^222 is a square n...原创 2018-09-01 20:26:49 · 1970 阅读 · 0 评论 -
A Question of Ingestion
5028: A Question of Ingestion时间限制: 1 Sec 内存限制: 128 MB提交: 89 解决: 24[提交] [状态] [讨论版] [命题人:admin]题目描述Stan Ford is a typical college graduate student, meaning that one of the most important thing...原创 2018-09-03 19:53:40 · 318 阅读 · 0 评论 -
ACM-ICPC 2018 沈阳赛区网络预赛G-Spare Tire
说起来这题和这个挺像的传送门区别就是推导出来的函数不太一样,其他差不多一样 推导,得出通项an = n*(n+1)对于ap+a2p+a3p+******+akp = p*(k+1)*k/2 +p*p* k*(k+1)*(2*k+1)/6特别的:p = 1,即{an}的前n项和 = (k+1)*k/2 + k*(k+1)*(2*k+1)/6那么将m唯一分解,用容...原创 2018-09-08 19:33:30 · 387 阅读 · 0 评论 -
ACM-ICPC 2018 徐州赛区网络预赛H
Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, each book has its knowledge a[i]a[i].Unfortunately, the longer he learns, the fewer he gets.Tha...原创 2018-09-09 20:09:04 · 461 阅读 · 0 评论 -
9264: Chip Factory(字典树
9264: Chip Factory时间限制: 5 Sec 内存限制: 128 MB提交: 269 解决: 62[提交] [状态] [讨论版] [命题人:admin]题目描述John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large a...原创 2018-10-04 11:34:20 · 175 阅读 · 0 评论 -
Connect3
9311: Connect3时间限制: 1 Sec 内存限制: 256 MB提交: 50 解决: 24[提交] [状态] [讨论版] [命题人:admin]题目描述Connect3 is a simplified version of a well-known Connect4 game. Connect3 is a game for two players, black an...原创 2018-10-04 22:25:05 · 1192 阅读 · 0 评论 -
Coins I
5212: Coins I时间限制: 1 Sec 内存限制: 128 MB提交: 114 解决: 69[提交] [状态] [讨论版] [命题人:admin]题目描述Alice and Bob are playing a simple game. They line up a row of n identical coins, all with the heads facing ...转载 2018-08-23 09:47:28 · 269 阅读 · 0 评论 -
Sum of the Line
5222: Sum of the Line 时间限制: 1 Sec 内存限制: 128 MB ...原创 2018-08-22 09:59:34 · 167 阅读 · 0 评论 -
最短Hamilton路径(状压DP)
问题 C: 最短Hamilton路径 时间限制: 2 Sec 内存限制: 128 MB题目描述给定一张 n(n≤20) 个点...原创 2018-08-18 15:49:40 · 522 阅读 · 0 评论 -
法里数列、小结
这叫Stern-Brocot树,其中真分数(左边),叫法里数列(Farey 数列)上图是一棵Stern-Brocot树,其生成规则如下:从第1行到第n行,每行相邻两数a/b和c/d,产生中间数(a+c)/(b+d),置于下一行中。将一行的分数(包括0/1,1/0),进行约分简化,则每一行(包括0/1,1/0,1/1),不会出现两个相同的分数。若分子或者分母大于n,则去掉该分数,将...原创 2019-08-14 11:59:26 · 708 阅读 · 0 评论 -
AtCoder Beginner Contest 121-D - XOR World
给你一个区间输出l^(l+1)......^r的值找了半天规律,发现方向错了,巨特么复杂,结束后发现很简单对于F(n) = 0^1^2....……^n其满足long long xor1_a(long long a){ if(a%4==1) return 1ll; if(a%4==2) return a+1; if(a%4==...原创 2019-03-10 10:37:42 · 340 阅读 · 0 评论 -
EOJ Monthly 2019.2 D. 进制转换
题目链接、 单测试点时限: 2.0 秒内存限制: 256 MB“他觉得一个人奋斗更轻松自在。跟没有干劲的人在一起厮混,只会徒增压力。”QQ 小方决定一个人研究研究进制转换。很快,QQ 小方就遇到问题了。他现在想知道在十进制范围 [l,r] 内有多少整数满足在 k 进制下末尾恰好有 m 个 0。比如在十进制下的 24 在二进制下是 11000,我们称十进制下的 24 在二...原创 2019-02-23 09:11:03 · 446 阅读 · 0 评论 -
D - Array Without Local Maximums (dp)
题目链接题意:有一个长度为N的序列(2≤n≤1e5)满足关系:a1≤a2,an≤an−1,ai≤max(ai−1,ai+1)。每一个ai的范围是[1,200],有一些ai是确定的,有一些是不确定的,问有多少种情况。答案对998244353取模。 相当于说是对于任意三个相邻的三个数a[i-1],a[i],a[i+1],只排出了a[i]>a[i-1],a[i]>a[...原创 2018-11-27 10:54:41 · 145 阅读 · 0 评论 -
codeforces round#522-E-The Unbearable Lightness of Weights-----多重背包
You have a set of nn weights. You know that their masses are a1, a2, ..., anan grams, but you don't know which of them has which mass. You can't distinguish the weights.However, your friend does kno...原创 2018-11-29 14:58:03 · 301 阅读 · 0 评论 -
6360: 词韵
6360: 词韵时间限制: 2 Sec 内存限制: 128 MB提交: 168 解决: 30[提交] [状态] [讨论版] [命题人:admin]题目描述Adrian 很喜欢诗歌中的韵。他认为,两个单词押韵当且仅当它们的最长公共 后缀的长度至少是其中较长单词的长度减一。也就是说,单词 A 与单词 B 押韵 当且仅当 LCS(A, B) ≥ max(|A|, |B|) – 1。(...转载 2018-08-03 10:56:02 · 370 阅读 · 0 评论 -
问题 F: Connected?
问题 F: Connected?时间限制: 1 Sec 内存限制: 128 MB提交: 38 解决: 20[提交] [状态] [讨论版] [命题人:admin]题目描述Snuke is playing a puzzle game. In this game, you are given a rectangular board of dimensions R×C, filled ...原创 2018-08-04 16:44:00 · 279 阅读 · 2 评论 -
6617: Finite Encyclopedia of Integer Sequences
6617: Finite Encyclopedia of Integer Sequences时间限制: 1 Sec 内存限制: 128 MB提交: 341 解决: 75[提交] [状态] [讨论版] [命题人:admin]题目描述In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences o...原创 2018-08-04 21:00:01 · 184 阅读 · 0 评论 -
P4461 [CQOI2018]九连环(找规律,大数)
题目背景九连环是一种源于中国的传统智力游戏。如图所示,九个的圆环套在一把“剑”上,并且互相牵连。游戏的目标是把九个圆环全部从“剑”上卸下。题目描述圆环的装卸需要遵守两个规则: 第一个(最右边) 环任何时候都可以任意装上或卸下 如果第k 个环没有被卸下,且第k 个环右边的所有环都被卸下,则第k+1个环(第k 个环左边相邻的环) 可以任意装上或卸下 与魔方的千...原创 2018-08-07 18:08:45 · 444 阅读 · 0 评论 -
Exponial欧拉降幂
时间限制: 1 Sec 内存限制: 64 MB提交: 255 解决: 67[提交] [状态] [讨论版] [命题人:外部导入]题目描述Illustration of exponial(3) (not to scale), Picture by C.M. de Talleyrand-Périgord via Wikimedia Commons Everybody loves bi...原创 2018-10-07 10:39:25 · 328 阅读 · 0 评论 -
ArtWork(并查集--二维降一维)
3030: ArtWork时间限制: 4 Sec 内存限制: 128 MB提交: 49 解决: 22[提交] [状态] [讨论版] [命题人:外部导入]题目描述A template for an artwork is a white grid of n × m squares. The artwork will be created by painting q horizont...原创 2018-10-08 22:21:13 · 392 阅读 · 0 评论 -
FATE--HDU-2159
FATETime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 19229 Accepted Submission(s): 9037Problem Description最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,...原创 2018-10-21 19:59:46 · 189 阅读 · 0 评论 -
Boxes
时间限制: 2 Sec 内存限制: 256 MB 题目描述There are N boxes arranged in a circle. The i-th box contains Ai stones.Determine whether it is possible to remove all the stones from the boxes by repeatedly perfo...原创 2018-04-24 11:07:04 · 244 阅读 · 0 评论 -
CodeForces - 977E,E. Cyclic Components
E. Cyclic Componentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph consisting of nn vertices ...原创 2018-05-14 17:20:17 · 512 阅读 · 0 评论 -
容斥定理 -- 第九届ACM山东省赛F题 Four-tuples
Four-tuples Time Limit: 2000 msMemory Limit: 524288 KiBOutputFor each test case, output one line containing one integer, representing the answer.Sample Input11 1 2 2 3 3 4 4Sam...原创 2018-05-15 20:19:18 · 232 阅读 · 0 评论 -
高橋君とカード / Tak and Cards(dp)
Time limit : 2sec / Memory limit : 256MBScore : 300 pointsProblem StatementTak has N cards. On the i-th (1≤i≤N) card is written an integer xi. He is selecting one or more cards from these N card...原创 2018-05-20 21:00:13 · 313 阅读 · 0 评论 -
Iroha and a Grid(组合数学,逆元)
Iroha and a Grid时间限制: 1 Sec 内存限制: 128 MB题目描述We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacen...原创 2018-05-21 20:36:54 · 380 阅读 · 0 评论 -
【动态规划】传纸条
题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题。一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了。幸运的是,他们可以通过传纸条来进行交流。纸条要经由许多同学传到对方手里,小渊坐在矩阵的左上角,坐标(1,1),小轩坐在矩阵的右下角,坐标(m,n)。从小渊传到小轩的纸条只可以向下或者向右传递,...原创 2018-05-23 21:00:14 · 512 阅读 · 0 评论 -
缺失的数据范围
著名出题人小Q出过非常多的题目,在这个漫长的过程中他发现,确定题目的数据范围是非常痛苦的一件事。 每当思考完一道题目的时间效率,小Q就需要结合时限以及评测机配置来设置合理的数据范围。 因为确定数据范围是一件痛苦的事,小Q出了非常多的题目之后,都没有它们设置数据范围。对于一道题目,小Q会告诉你他的算法的时间复杂度为O(nalogbn)O(nalogbn),且蕴含在这个大OO记号下的常数为11。...原创 2018-06-01 21:21:51 · 300 阅读 · 0 评论 -
华为杯--山理工---E剪子-包袱-锤
剪子-包袱-锤Time Limit: 1000 ms Memory Limit: 65536 KiBSpecial JudgeSubmit StatisticProblem Description“石头、剪刀、布”是猜拳的一种,两人玩,起源于中国,然后传到日本、韩国等地,随着亚欧贸易的不断发展传到了欧洲,到了近现代逐渐发展到世界。游戏规则中,石头克剪刀,剪刀克布,布克石头。...原创 2018-06-10 17:55:13 · 269 阅读 · 0 评论 -
"巴卡斯杯" 中国大学生程序设计竞赛 - 2016年女生赛--D--Clock
Given a time HH:MM:SS and one parameter aa, you need to calculate next time satisfying following conditions: 1. The angle formed by the hour hand and the minute hand is aa. 2. The time may not be...原创 2018-06-14 19:59:21 · 392 阅读 · 0 评论 -
5727: 小奇遐想
5727: 小奇遐想时间限制: 1 Sec 内存限制: 128 MB提交: 243 解决: 44[提交] [状态] [讨论版] [命题人:admin]题目描述撷来一缕清风飘渺方知今日书信未到窗外三月天霁垂柳新长枝条风中鸟啼犹带欢笑——《清风醉梦》小奇望着青天中的悠悠白云,开始了无限的遐想,在它的视野中,恰好有n朵高度不同的白云排成一排,他想从左到右选出四朵白云a,b,...转载 2018-07-28 09:40:34 · 163 阅读 · 0 评论 -
Barareh on Fire
题目描述The Barareh village is on fire due to the attack of the virtual enemy. Several places are already on fire and the fire is spreading fast to other places. Khorzookhan who is the only person re...原创 2018-04-22 21:53:56 · 146 阅读 · 0 评论 -
蓝桥杯——排列序数——康拓展开(全排列)
排列序数题目描述X星系的某次考古活动发现了史前智能痕迹。这是一些用来计数的符号,经过分析它的计数规律如下:(为了表示方便,我们把这些奇怪的符号用a~q代替)abcdefghijklmnopq 表示0abcdefghijklmnoqp 表示1abcdefghijklmnpoq 表示2abcdefghijklmnpqo 表示3abcdefghijklmnqop 表示4abc...原创 2018-03-27 11:59:37 · 574 阅读 · 0 评论 -
剪邮票——蓝桥杯
1237: 剪邮票时间限制: 1 Sec 内存限制: 128 MB题目描述如【图1.jpg】, 有12张连在一起的12生肖的邮票。现在你要从中剪下5张来,要求必须是连着的。(仅仅连接一个角不算相连)比如,【图2.jpg】,【图3.jpg】中,粉红色所示部分就是合格的剪取。请你计算,一共有多少种不同的剪取方法。请填写表示方案数目的整数。注意:你提交的应该是一个整数,不要填...原创 2018-03-24 11:02:20 · 299 阅读 · 0 评论