codeforces
文章平均质量分 82
h1021456873
这个作者很懒,什么都没留下…
展开
-
codeforces 792 C. 删除尽量少的位数后是3的倍数 (取余问题+分类讨论+模拟吧)
题意:给出一个正整数n,问用最少的删除操作是它变成美丽数。 美丽数的定义:没有前导0,且是3的倍数。输出任意美丽数,无解输出-1。 题解:是三的倍数,和也是三的倍数。求和mod3之后,有三种情况, 1:和为0,即本身就是美丽数,直接输出。 2:和为1,此时应该删除一个1(mod3为1,下同)或者两个2。 3:和为2,此时应该删除一个2或者两个1。原创 2017-04-16 17:11:59 · 695 阅读 · 0 评论 -
codeforces 721D D. Maxim and Array (STL||优先队列)
Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integerx and decided to add or subtract it from arbitrary arr原创 2016-11-27 14:58:25 · 309 阅读 · 0 评论 -
codeforces 719 C Efim and Strange Grade (模拟)
Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasan原创 2016-11-22 21:31:21 · 348 阅读 · 0 评论 -
codeforces 721 Journey (拓扑序+DP)
Recently Irina arrived to one of the most famous cities of Berland — the Berlatov city. There aren showplaces in the city, numbered from 1 to n, and some of them are connected by one-directional r原创 2016-11-22 10:42:24 · 311 阅读 · 0 评论 -
codeforces 731 D 80-th Level Archeology (差分+线段扫描)
Archeologists have found a secret pass in the dungeon of one of the pyramids of Cycleland. To enter the treasury they have to open an unusual lock on the door. The lock consists ofn words, each cons原创 2016-11-20 15:10:38 · 721 阅读 · 0 评论 -
codeforces 722 C Destroying Array (逆向思维+并查集 || STL模拟)
You are given an array consisting of n non-negative integersa1, a2, ..., an.You are going to destroy integers in the array one by one. Thus, you are given the permutation of integers from1 to n原创 2016-11-19 19:37:25 · 396 阅读 · 0 评论 -
codeforce 732e Sockets (贪心)
The ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity su原创 2016-11-15 19:53:28 · 453 阅读 · 0 评论 -
codeforce 723d Lakes in Berland(暴力DFS)
The map of Berland is a rectangle of the size n × m, which consists of cells of size1 × 1. Each cell is either land or water. The map is surrounded by the ocean.Lakes are the maximal regions of原创 2016-11-13 16:00:48 · 256 阅读 · 0 评论 -
codeforce 724D Dense Subsequence (字符串||贪心好题)
You are given a string s, consisting of lowercase English letters, and the integerm.One should choose some symbols from the given string so that any contiguous subsegment of lengthm has at least原创 2016-11-13 00:56:42 · 400 阅读 · 0 评论 -
cf 377 D. Exams (安排考试||二分答案)
Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m.About every day we know exam for which one of m subjects can be p原创 2016-11-06 14:51:02 · 850 阅读 · 1 评论 -
cf 731 F. Video Cards (思维好题)
Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the原创 2016-11-06 13:48:47 · 435 阅读 · 0 评论 -
cf23C Oranges and Apples (贪心_好题)
给你2*n-1个篮子,分别装有若干苹果跟橘子,问取出n个篮子,使得苹果的总量占苹果sum的一半以上,且橘子也占橘子sum二等一半以上仔细观察数据,你会发现这是一个贪心策略、。。。我们一开始排序会想到,苹果从大往小排,去前n个,但不能保证橘子能占一半以上...那么如果有两个橘子,我们当然取最大的最好,那么如果我们每次取橘子最大的,并舍弃另一个,那么橘子能保证了,但原创 2016-03-29 12:43:02 · 740 阅读 · 0 评论 -
cf25d 修路使其联通 (并查集)
题意是给出n个城市,n-1条路,每天会修路(删除原本的一条路,然后增添一条新路)这题的亮点就在路只有n-1条,要联通的话只能有一个祖先,且不存在回路...故只要删除有回路的,然后把每个不相连的路连接起来即可....Berland Government decided to improve relations with neighb原创 2016-03-29 12:19:38 · 407 阅读 · 0 评论 -
cf20B Ax2 + Bx + C = 0 (分类讨论)
已知A,B,C的值,求根的个数....讨论一下系数的情况即可...DescriptionYou are given an equation:Ax2 + Bx + C = 0.Your task is to find the number of distinct roots of the equation and print all of them in asce原创 2016-04-08 17:51:22 · 1114 阅读 · 0 评论 -
cf19B Checkout Assistant (01背包_好题)
题意:有n个商品,每个商品都有一个付款时间t,和一个价值p,付款的时候可以偷走一个东西,花费1时间....问所以商品获得后最少要花多少钱...转换一下啊思路,这题就是已知一个商品单价p,同时送t个物品,即p元可以买t+1个商品,问n个商品买完,至少要花多少钱...操蛋,想了一天,最后还是看题解才搞定的////...那么其实很简单,就是一个01背包问题原创 2016-04-06 15:39:26 · 1055 阅读 · 0 评论 -
cf19A World Football Cup (排序)
题意很简单,就是排个序,然后输入的时候注意下就ok了Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held原创 2016-04-05 14:26:01 · 492 阅读 · 0 评论 -
cf18D Seller Bob (线性DP_好题)
题意:题目告诉你你能够按顺序获得一些价值为2^x的硬盘,你可以保留一个并且在之后的几天卖掉,但是你在卖掉当前这个之前是不能保留其他的硬盘的,在已经知道什么时候会有人买什么类型的硬盘的前提下,问你能获得的最大收益是多少。dp[i]表示当前i个序列中能获得的最大值... pre[t] 维护内存为t的最近的序列....最后用高精度即可Last year Bob ear原创 2016-04-05 10:58:59 · 420 阅读 · 0 评论 -
cf18B Platforms (贪心策略_好题)
题意:给出n快板,间隔一定长度(已知),且每块板的长度相等(已知),一个青蛙从原点0起跳,每次跳d距离远,问最后青蛙会落在哪里(没落在板子上就结束跳跃)....贪心策略,我是这么认为的,从小到大枚举板子的长度,然后每次先判断,如果青蛙落在板子前面,那么一定已经落水了,如果没有,使青蛙每次都落在当前板子的后面...DescriptionIn one one原创 2016-04-04 21:00:10 · 628 阅读 · 0 评论 -
codeforces 734 E. Anton and Tree (黑红树,缩点+dfs)
Anton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph.There are n vertices in the tree, each of them is painted black or white. Anton doesn't li原创 2016-11-27 20:08:13 · 524 阅读 · 0 评论 -
codeforce 735 C. Tennis Championship (斐波那契数列||网球比赛)
题意:问你冠军最多能赢多少场比赛,然后一个人只能和赢得场数最多相差一的人进行比赛,如果一个人输掉了比赛,那么他就失去了继续比赛的资格。思路:这题的突破口已经很明显暗示你了,最多相差一个人 才能进行比赛, 那我们可以考虑 冠军打n场比赛最少要几个人, 那么很容易想到这个一个斐波那契数列Famous Brazil city Rio de Janeiro holds a te原创 2016-12-16 21:14:10 · 350 阅读 · 0 评论 -
codeforces 735 D. Taxes (三素数||哥德巴赫猜想)
题意:就是把一个数字分解成质数,最少分几个。比如样例,4分为2+2,27分为17+3+7,当然质数本身就不用分了,直接输出1就行了。强哥德巴赫猜想 每个不小于 6 的偶数都是两个奇素数之和。弱哥德巴赫猜想 每个不小于 9 的奇数都是三个奇素数之和思路:那么如果是偶数,等于两个奇素数之和 如果是奇数,等于2+素数 或者 三个素数 Mr.原创 2016-12-16 21:20:51 · 549 阅读 · 0 评论 -
codeforces 792 B. Counting-out Rhyme (模拟链表||约瑟夫环)
题意:n个人占成一圈,每点ai个人淘汰一个,输出淘汰顺序 解题思路:直接用数组模拟链表遍历即可n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In th原创 2017-04-16 16:00:10 · 436 阅读 · 0 评论 -
Codeforces 789E The Great Mixing (数推倒公式 + bfs + 剪枝)
题意:有k个数,是1/1000的倍数,问能否选取任意个数,每个数也能选任意次,使他们的均值为n/1000题解:假设选了m个数 (s1+s2+...sm)/1000/m=n/1000,化简后得到(s1-n)+(s2-n)+....+(sm-n)=0,原题转化成从k个数中选m个数使他们的和为0,且选出来的数的和的范围必然是在[-1000,1000],这样用bfs来写,就可以得到最少需要选几个数原创 2017-04-16 13:30:14 · 563 阅读 · 0 评论 -
codeforces 789 D. Weird journey (欧拉路计数)
题意:给你一张n个点m条边的图,问你经过其中m-2条边两次,剩下2条边一次的方案数有几种,如果剩下两条边的集合一样算同一种题解:把题意转换成,我们挑选两条边,把其他的边都变成两条,这样就变成了一笔画问题(欧拉路径是否存在),我们欧拉路径存在的充要条件是奇点个数是0或2,。然后下面需要进行分类讨论,我们把边分成普通变和自环(u=v)两类。1.选取两条不相邻普通边,图中存在4个奇点,不原创 2017-04-16 10:33:14 · 351 阅读 · 0 评论 -
codeforce 789 C Functions again (dp)
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arr原创 2017-04-16 00:01:41 · 477 阅读 · 0 评论 -
Codeforces 796D Police Stations (bfs+思维)
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.Ruling a country is not an easy job. Thieves and terrorists are always ready to原创 2017-04-15 17:52:15 · 602 阅读 · 0 评论 -
codeforce 796 c Bank Hacking (思维题,分类讨论)
Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has原创 2017-04-15 11:03:31 · 697 阅读 · 0 评论 -
codeforce 738 C Road to Cinema 选车 (二分)
题意:你将从0点开车到s点,路上有一些加油站,加油时间忽略不计。你有两种开车选择,一种是每km走1min,花费2L油,另一种是每km走2min,花费1L油。你有n种汽车可以选择,给出它们的油箱容量(刚开始满的)和价格,能否选择一辆价格最低的车,能在时间t内跑完全程?如果不能输出-1解题:直接二分油量,最低的油量需要多少.... 再进行选车, 速度选择上面稍加思考就能出!原创 2017-02-26 11:18:30 · 434 阅读 · 1 评论 -
codeforce 777e Hanoi Factory 叠塔(贪心,从后往前推)
Of course you have heard the famous task about Hanoi Towers, but did you know that there is a special factory producing the rings for this wonderful game? Once upon a time, the ruler of the ancient Eg原创 2017-02-25 14:12:30 · 969 阅读 · 0 评论 -
codeforces 727F. Polycarp's problems DP or 二分预处理答案
题目链接:http://codeforces.com/contest/727/problem/F 题目大意:有n个问题,每个问题有一个价值ai,一开始的心情值为q,每当读到一个问题时,心情值将会加上该问题的价值。问题只能按顺序读。有m个询问,求当q=bi时,至少要删去多少个问题才能使得在任何时候心情值都>=0。 数据范围:1 ≤ n ≤ 750, 1 ≤ m ≤ 200 000, - 10原创 2017-02-24 10:50:47 · 577 阅读 · 0 评论 -
Codeforces 450B f【n】=f【n-1】-f【n-2】(矩阵快速幂,裸题)
Jzzhu has invented a kind of sequences, they meet the following property:You are given x and y, please calculate fn modulo1000000007 (109 + 7).InputThe first line contains two inte原创 2017-03-07 23:45:25 · 770 阅读 · 0 评论 -
codeforce 754 C. Vladik and chat 安排人说话 (经典DP题)
Recently Vladik discovered a new entertainment — coding bots for social networks. He would like to use machine learning in his bots so now he want to prepare some learning data for them.At first,原创 2017-02-09 15:29:01 · 959 阅读 · 0 评论 -
codeforce 754 D k个区间的交的尽可能的大 (优先队列) 贪心好题!!!
题意:给定n个区间,现在让你从这n个区间里面选k个区间,使得这k个区间的交的尽可能的大。先给区间按 左端点排序思路:枚举左端点,用优先队列维护右端点,然后动态的更新答案即可!!!!All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighbori原创 2017-02-08 21:09:59 · 457 阅读 · 0 评论 -
codeforce 749 D. Leaving Auction 拍卖 (set+二分) 思维题!!!
题目大意(源自CF群):有n每一次出价都是一个整数对(a[i],b[i])(a[i]有q每一个询问包含一个整数k以及k个人的编号l[j],保证k的总和不会超过2e5问如果这些人不出现的话,谁会获得这件商品?对于每一个询问,输出两个整数,胜出者的编号以及胜出者出的价格,如果没有人胜出,输出两个0.思路:用set >pos维护竞价人的下标和最大值,把最大值作为p原创 2017-02-08 12:17:24 · 448 阅读 · 0 评论 -
codeforce 742 E. Arpa’s overnight party and Mehrdad’s silent entering (分食物||二分图染色+dfs)
Note that girls in Arpa’s land are really attractive.Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He sawn pairs of friends sitting around a table.原创 2016-12-18 20:27:18 · 376 阅读 · 0 评论 -
codeforce B. Chloe and the sequence (递归)
Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad.Let's consider the原创 2016-12-17 20:43:42 · 383 阅读 · 0 评论 -
codeforce 743 D. Chloe and pleasant prizes (树形dp)
Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Chr原创 2016-12-17 20:04:44 · 440 阅读 · 0 评论 -
codeforce 743 C. Vladik and fractions (数学构造)
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integern he can represent fraction as a sum of three distinct positive fractions in form原创 2016-12-17 16:14:35 · 373 阅读 · 0 评论 -
cf246 ENew Reform (并查集找环)
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from原创 2016-04-02 12:26:28 · 981 阅读 · 0 评论 -
cf628B 求字符串的字串有多少个能整除4 (找规律)
因为100是4的倍数,那么只要先暴力一遍一位数的,满足要求的+1然后在暴力2位数的,符合要求的+前缀....之前训练赛有做过类似的题目,所以....so eazyDescriptionMax wants to buy a new skateboard. He has calculated the amount of money that is needed to b原创 2016-03-30 01:15:17 · 1055 阅读 · 0 评论