HDU 6136 Death Podracing(循环链表)】的更多相关文章

[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6136 [题目大意] 一堆人在操场上跑步,他们都有一定的速度和初始位置, 当两个人相遇的时候编号较小的就会出局,当场上剩下最后一个人的时候游戏结束, 问时长为多少 [题解] 我们发现每次发生碰撞的一定是相邻的两个人, 所以我们找出相邻关系中最先发生碰撞的,将碰撞失败的那个人删除, 之后继续这个过程, 按照上述的做法我们建立一个循环链表,把所有人串起来, 当发生淘汰的时候把那个人从循环链表中删去即可…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=6136 题解 完了,普及题都不会做了... 发现一个重要性质是只有相邻的人才会相撞,于是直接拿堆维护即可... WA了好几发... 代码 #include<cstdio> #include<cstdlib> #include<cstring> #include<queue> #include<algorithm> #define llong long…
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-size: 10.5000pt } h1 { margin-top: 5.0000pt; margin-bottom: 5.0000pt; text-align: center; font-family: 宋体; color: rgb(26,92,200); font-weight: bold; fo…
HDU 5860 Death Sequence(递推) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 Description You may heard of the Joseph Problem, the story comes from a Jewish historian living in 1st century. He and his 40 comrade soldiers were trapped in a cave…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 题目大意:给你n个人排成一列编号,每次杀第一个人第i×k+1个人一直杀到没的杀.然后剩下的人重新编号从1-剩余的人数.按照上面的方式杀.问第几次杀的是谁. 分析 一轮过后和原来问题比只是人的编号发生变化,故可以转化为子问题求解,不妨设这n个人的编号是0~n-1,对于第i个人,如果i%k=0,那么这个人一定是第一轮出列的第i/k+1个人:如果i%k!=0,那么这个人下一轮的编号就是i…
Problem Description You may heard of the Joseph Problem, the story comes from a Jewish historian living in 1st century. He and his 40 comrade soldiers were trapped in a cave, the exit of which was blocked by Romans. They chose suicide over capture an…
用线段树可以算出序列.然后o(1)询问. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include&l…
Yong Zheng's Death Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 224    Accepted Submission(s): 37 Problem Description Some Chinese emperors ended up with a mysterious death. Many historia…
题目链接:HDU-5129 题目大意为给一堆字符串,问由任意两个字符串的前缀子串(注意断句)能组成多少种不同的字符串. 思路是先用总方案数减去重复的方案数. 考虑对于一个字符串S,如图,假设S1,S2,S3,S4,S5,S6均为前缀. 换言之,对于这种字符串,我们计算了三次. 发现,重复的方案数,等于中间如图有颜色的方块的数量.所以我们要做的也就是计数像图中有颜色的小方块的数量. 我们可以通过遍历像S6一样的字符串的数量,来计算重复的方案数.S6满足以下条件: 存在一个前缀S4为S6的后缀,且S…
题目传送: Hybrid Crystals Problem Description > Kyber crystals, also called the living crystal or simply the kyber, and known as kaiburr crystals in ancient times, were rare, Force-attuned crystals that grew in nature and were found on scattered planets…