![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
思维好题
薄层
努力就有收获~
展开
-
HDU-6205 card card card(思维+简单线段树)
2017 ACM/ICPC Asia Regional Shenyang OnlineAs a fan of Doudizhu, WYJ likes collecting playing cards very much. One day, MJF takes a stack of cards and talks to him: let's play a game and if you win, you can get all these cards. MJF randomly assigns these原创 2017-09-11 13:27:18 · 600 阅读 · 0 评论 -
QDU 良辰最喜欢良辰最喜欢对那些自认能力出众的人出手(Lucas定理推广)
果果一直很谦虚,但是良辰还是对他出手了(汗。。良辰拿出来一个 Pascal 三角形(也叫杨辉三角形。(请不要问是怎么拿出来的。。我们用一个矩阵来表示 Pascal 三角形0: C(0, 0)1: C(1, 0) C(1, 1)2: C(2, 0) C(2, 1) C(2, 2)...其中最左边的数字表示行号。C(x, y) 表示一个组合数,即 x 个元素中取 y 个的方法数。良辰只有一个问题:Pascal 三角形中的第 n 行有多少个奇数?这样的问题对于果果来说太水了,于原创 2017-06-29 21:19:43 · 373 阅读 · 0 评论 -
QDU BelamiYao的一道简单签到题(思维)
描述BelamiYao得到了一个数列,但BelamiYao想把数列中所有的数都变成同一个数,然而BelamiYao只有两种nr4数字膜法,每一秒只能使用一种膜法1.将一个数乘2.2.将一个数除2,并向下取整。BelamiYao想问你最少需要花费多少秒才能将数列中所有的数都变成同一个数。输入第一行一个整数n代表数列中数字的个数接下来n个整数。保证输入所有数据均小于100000原创 2017-06-15 22:56:49 · 531 阅读 · 0 评论 -
美团CodeM初赛B轮-黑白树(树形结构贪心)
一棵n个点的有根树,1号点为根,相邻的两个节点之间的距离为1。树上每个节点i对应一个值k[i]。每个点都有一个颜色,初始的时候所有点都是白色的。你需要通过一系列操作使得最终每个点变成黑色。每次操作需要选择一个节点i,i必须是白色的,然后i到根的链上(包括节点i与根)所有与节点i距离小于k[i]的点都会变黑,已经是黑的点保持为黑。问最少使用几次操作能把整棵树变黑。原创 2017-07-09 23:31:00 · 471 阅读 · 0 评论 -
UESTC-1006 最长上升子序列(最长递减子序列做法+贪心策略)
一个数的序列B=(b1,b2,⋯,bS)B=(b1,b2,⋯,bS),当b1<b2<⋯<bSb1<b2<⋯<bS 的时候,我们称这个序列是上升的。对于给定的一个序列A=(a1,a2,⋯,aN)A=(a1,a2,⋯,aN),我们可以得到一些上升的子序列(ai1,ai2,⋯,aiK)(ai1,ai2,⋯,aiK),这里1≤i1<i2<⋯<iK≤N1≤i1<i2<⋯<iK≤N。比如,对于序列(1,7,3,5,9,4,8)(1,7,3,5,9,4,8),有它的一些上升子序列,如(1,7)(1,7), (3,4,8)原创 2017-07-09 23:13:44 · 831 阅读 · 0 评论 -
sdut 3258 (第六届山东省ACM省赛H题)
题意:一个数可以表示为另一个数的平方叫做square number,像3*3 = 9,9是一个square number。给定n个数,求有多少对(ai,bi)满足ai×bi为一个square number,其中i != j。思路:除1之外的任何一个整数都可分解为有限个质数的乘积,所以可以推得两个数分解为质因数乘积之后的乘积,只有满足任意一个质因数的个数为偶数个时,它们的乘积原创 2017-04-30 17:04:57 · 400 阅读 · 0 评论 -
2014-2015 ACM-ICPC, NEERC, Northern Subregional Contest I-Instruction(模拟)
Ingrid is a head of a big railway station and, among other duties, is responsible for routing trains to theright platforms. The station has one entrance, and there are many switches that direct trains to otherswitches and platforms.Each switch has one i原创 2017-10-07 20:52:15 · 482 阅读 · 0 评论 -
CodeForces-835E The penguin's game(思维+二进制乱搞+交互题)
Pay attention: this problem is interactive.Penguin Xoriy came up with a new game recently. He has n icicles numbered from 1 to n. Each icicle has a temperature — an integer from 1 to 109. Exactly two of these icicles are special: their temperature is y, w原创 2017-08-31 14:14:27 · 336 阅读 · 0 评论 -
CodeForces-839B Game of the Rows(思维、细节)
Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea.原创 2017-08-16 23:59:39 · 244 阅读 · 0 评论 -
Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)-831C Jury Marks(思维)
Jury MarksPolycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one a原创 2017-07-14 23:59:55 · 382 阅读 · 0 评论 -
HDU-6058 Kanade's sum - 2017 Multi-University Training Contest - Team 3(思维+模拟链表)
Give you an array A[1..n]A[1..n]of length nn. Let f(l,r,k)f(l,r,k) be the k-th largest element of A[l..r]A[l..r]. Specially , f(l,r,k)=0f(l,r,k)=0 if r−l+1<kr−l+1<k. Give you kk , you need to calculate ∑nl=1∑nr=lf(l,r,k)∑l=1n∑r=lnf(l,r,k) There are T test原创 2017-08-01 20:09:27 · 402 阅读 · 0 评论 -
CodeForces 606C
车辆排序CodeForces 606CDescription一个无限长的铁路有一个载着n辆车的火车,每一辆车的编号从1到n。每一辆车的编号都是不同的。他们的顺序是无序的。David Blaine想要将这些车按照他们的编号从小到大排序,他可以做两种操作。第一种,他可以将一辆车从任意位置移动到所有车的第一位。第二种,他可以将一辆车从任意位置移动到所有车的最后一位。不过他原创 2016-11-04 00:05:18 · 598 阅读 · 0 评论 -
QDU no cer的一道简单签到题(线性递推)
他不仅回来了,还带回来了一块2*n的长板。然而他的蜜汁审美告诉他,这块长板需要贴瓷砖。但是nr4强者Cerberux只有两种瓷砖,一种是1*2的,一种是1*1的。他面对这块长板,突然脑抽了,想知道有多少种不同的用1*2和1*1瓷砖填满长板的方案。大家都知道,nr4强者Cerberux不是一天炼成的。他为了成为nr4强者,不仅舍弃了上课,拥抱了挂科,还离开了挚爱(个屁)的ACM。所以他怎么可能会自己动脑想这个和魔方无关的问题。于是nr4强者Cerberux想问你们有多少种填满长板的原创 2017-06-14 14:38:09 · 565 阅读 · 0 评论 -
QDU Julyc和CerberuX去吃饭后传(贪心、思维)
上次Julyc和CerberuX因为去吃饭打的不可开交,而一般人都不会想和CerberuX打架,Julyc也不例外。这次他们去了一条小吃街,小吃街里有n种小吃,Julyc和CerberuX口味不同,对于每一种小吃,每个人都有着各自的对这种小吃的喜爱值,虽然Julyc非常想独自行动,但是每次独自行动后CerberuX都会走丢(即使学校门口的小吃街),所以Julyc和CerberuX必须一起行动,也就是说他们要选择相同的小吃。先约定一个人“吃得好”是指他吃到的小吃的喜爱值(他对这种小吃的喜爱值)累加之和大于没吃原创 2017-08-29 04:35:34 · 323 阅读 · 0 评论 -
HDU 4883(区间选点贡献经典问题)
题意:有n组数据是客人到来和离开的时间以及所需的板凳数,问需要多少张桌椅才能满足所有客人来就都能有位置坐。思路:做法一:将区间左右端点都转换成分钟进行排序,如果是左端点,则贡献k,右端点则贡献-k。通俗点就是,把所有客人到来和离开的时间都转换成分钟数进行排序,每次客人到来需要k张桌椅,那么就+上k,每次客人离开就会返还k张桌椅,那么就-去k,求过程中的最大值。这和之前的一道cf题很原创 2017-06-10 13:39:29 · 385 阅读 · 0 评论 -
HDU-4908(思维之贡献问题)
题意:给一个N个数的序列,然后给出一个M,问以M为中位数的奇数长度的子序列序列个数。思路:训练时做的理解错题意了,一上来就连WA几次,中位数的概念都忘了,真是伤..中位数:一组按大小顺序排列起来的数据中处于中间位置的数。正解思路是:将大于m的数的位置贡献1,小于m的数的位置贡献-1,等于m的数的位置贡献0。然后找打最后一个等于m的位置,取其前面若干个以及其后面的若干个共奇数个的贡献总和为0原创 2017-06-20 23:56:36 · 352 阅读 · 0 评论 -
HDU-5792 World is Exploding(思维、树状数组+离散化)
Given a sequence A with length n,count how many quadruple (a,b,c,d) satisfies: a≠b≠c≠d,1≤a<b≤n,1≤c<d≤n,Aa<Ab,Ac>Ada≠b≠c≠d,1≤a<b≤n,1≤c<d≤n,Aa<Ab,Ac>Ad.InputThe input consists of multiple test cases. Each test case begin with an integer n in a single line原创 2017-09-02 17:22:06 · 302 阅读 · 0 评论 -
codeforces-884D Boxes And Balls(思维、三叉哈夫曼树)
Ivan has n different boxes. The first of them contains some balls of n different colors.Ivan wants to play a strange game. He wants to distribute the balls into boxes in such a way that for every i (1 ≤ i ≤ n) i-th box will contain all balls with color i.原创 2017-11-01 14:52:44 · 670 阅读 · 0 评论 -
POJ-1019 Number Sequence(思维题)
A single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2...Sk. Each group Sk consists of a sequence of positive integer numbers ranging from 1 to k, written one after another.原创 2017-07-31 21:21:55 · 710 阅读 · 0 评论 -
ZOJ-3987 Numbers 2017CCPC秦皇岛站G题 (二进制乱搞、贪心)
DreamGrid has a nonnegative integer . He would like to divide into nonnegative integers and minimizes their bitwise or (i.e. and should be as small as possible).InputThere are multiple test cases. The first line of input contains an integer , indica原创 2017-10-30 16:13:39 · 2370 阅读 · 1 评论 -
GYM 101128H Sheldon Numbers
原题如Description 问区间[x,y]中有多少数的二进制表示是ABAB..AB型或者A型的,其中A是n个1,B是m个0,n, m > 0 Input 两个整数x和y(0Output 输出[x,y]中有多少满足条件的数 Sample Input 1 10 Sample Output 10 思路:先构建模板,像110, 111原创 2017-03-27 11:52:53 · 617 阅读 · 0 评论 -
HDU-4424 Conquer a New Region(并查集)
The wheel of the history rolling forward, our king conquered a new region in a distant continent. There are N towns (numbered from 1 to N) in this region connected by several roads. It's confirmed that there is exact one route between any two towns. Traff原创 2017-10-02 00:36:45 · 230 阅读 · 0 评论 -
HDU-5459 Jesus Is Here(思维递推)
2015 ACM/ICPC Asia Regional Shenyang OnlineI've sent Fang Fang around 201314 text messages in almost 5 years. Why can't she make sense of what I mean? ``But Jesus is here!" the priest intoned. ``Show me your messages." Fine, the first message is s1=‘‘c"原创 2017-09-14 12:51:35 · 297 阅读 · 0 评论 -
HDU-6166 Senior Pan - 2017 Multi-University Training Contest - Team 9(最短路+二进制乱搞)
Senior Pan fails in his discrete math exam again. So he asks Master ZKC to give him graph theory problems everyday. The task is simple : ZKC will give Pan a directed graph every time, and selects some nodes from that graph, you can calculate the minimum d原创 2017-09-01 16:48:11 · 427 阅读 · 0 评论 -
HDU-6140 Killer Names - 2017 Multi-University Training Contest - Team 8(思维)
> 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 across the galaxy. They were used by the Jedi an原创 2017-08-17 20:14:13 · 245 阅读 · 0 评论 -
HDU-6105 Gameia - 2017 Multi-University Training Contest - Team 6(思维之找规律或二分图最大匹配)
Alice and Bob are playing a game called 'Gameia ? Gameia !'. The game goes like this : 0. There is a tree with all node unpainted initial. 1. Because Bob is the VIP player, so Bob has K chances to make a small change on the tree any time during the game原创 2017-08-11 23:59:49 · 287 阅读 · 0 评论 -
HDU-6060 RXD and dividing - 2017 Multi-University Training Contest - Team 3(思维+最小斯坦纳树)
RXD has a tree TT, with the size of nn. Each edge has a cost. Define f(S)f(S) as the the cost of the minimal Steiner Treeof the set SS on tree TT. he wants todivide2,3,4,5,6,n2,3,4,5,6,…n into kk parts S1,S2,S3,…SkS1,S2,S3,…Sk, where ⋃Si={2,3,…,n}⋃Si={2,3,原创 2017-08-01 22:26:38 · 582 阅读 · 0 评论 -
HDU-4886(hash+暴力枚举)
题意:给一个主串s(只包括‘A’‘B’‘C’‘D’‘E’‘F’‘G’‘H’),然后要找出一个串ans(也只包括‘A’‘B’‘C’‘D’‘E’‘F’‘G’‘H’),ans满足条件:在s所有子串中没出现过,其次保证长度最短,最后保证字典序最小。思路:可以估计ans的长度最长为7,因为要使主串s中存在所有的8个字符的排列需要长度为8^7,已经超过了题目给定长度。枚举所有长度的子串,然后将字符串哈希成原创 2017-06-21 12:39:39 · 434 阅读 · 0 评论 -
HDU-6215 Brute Force Sorting(思维、模拟链表)
2017 ACM/ICPC Asia Regional Qingdao OnlineBeerus needs to sort an array of NN integers. Algorithms are not Beerus's strength. Destruction is what he excels. He can destroy all unsorted numbers in the array simultaneously. A number A[i]A[i] of the array is原创 2017-11-11 16:21:10 · 446 阅读 · 0 评论