codeforces 299E Cube Problem】的更多相关文章

Cube Problem Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit   Status   Practice CodeForces 299E Description Yaroslav, Andrey and Roman love playing cubes. Sometimes they get together and play cubes for hours and hours! T…
link:http://codeforces.com/problemset/problem/340/C 开始一点也没思路,赛后看别人写的代码那么短,可是不知道怎么推出来的啊! 后来明白了. 首先考虑第一个数字,就是和0想减的内个.那么剩下的n-1个数字有(n-1)!个排列方式.所以呢,在n!个式子里面,第一个位置的和就是:a1 * (n-1)! + a2 * (n-1)! + ...... + an * (n-1)!: 然后考虑其它位置:对于ai , aj . 并且相邻.那么剩下 n - 2 个…
题目链接:http://codeforces.com/problemset/problem/337/B 看到这个题目,觉得特别有意思,因为有熟悉的图片(看过的一部电影).接着让我很意外的是,在纸上比划了一下,凭着直觉,竟然一次AC,那个兴奋啊 !^_^ !  好啦,不说废话. 这个题目被分类为 math 和 matrices ,数学还好理解,matrices,应该是母函数吧(不好意思的说,还没系统地学到),姑且让我分类到数学里吧.题目的意思是,给出一个水平长度 : 垂直长度的比例分别为 a:b…
http://codeforces.com/problemset/problem/527/D 题意:给出一些点的xi和wi,当|xi−xj|≥wi+wj的时候,两点间存在一条边,找出一个最大的集合,集合中的点两两之间存在边 化开有 xi-xj>=wi+wj ==> wj+xj<=wi-xi xj-xi>=wi+wj ==> wi+wx<=wj-xj 发现本质相同,我们按x+w排序,从最小的往大的贪心连边,因为如果有一条边,那么比它小的也全部可以连到边. #include…
题目链接:https://codeforces.com/problemset/problem/706/C 题意: 给出 $n$ 个字符串,对于第 $i$ 个字符串,你可以选择花费 $c_i$ 来将它整个翻转. 要你尽量用最少的花费,使得 $n$ 个字符串按照字典序升序排序. 题解: $f[i][0,1]$ 表示前 $i$ 个字符串,第 $i$ 个不翻转(或者翻转)的情况下,最少的花费. AC代码: #include<bits/stdc++.h> using namespace std; typ…
题目链接:http://codeforces.com/problemset/problem/1096/D 题意: 给出一个小写字母组成的字符串,如果该字符串的某个子序列为 $hard$,就代表这个字符串是不好的. 现在你要删掉若干字母,使得字符串是好的,同时删除第 $i$ 个字母会使得歧义程度增加 $a[i]$,你需要让歧义程度最低,输出这个值. 题解: $dp[i][x=0,1,2,3]$ 的状态是前 $i$ 个字母,第二维 $x$ 代表:$0$——不包含任何有可能构成 “$hard$” 的子…
题目链接:http://codeforces.com/problemset/problem/793/C 题目大意:给你一个捕鼠器坐标,和各个老鼠的的坐标以及相应坐标的移动速度,问你是否存在一个时间点可以关闭捕鼠器抓住所有的老鼠,误差不能超过1e-6. 解题思路:可以把每个老鼠进入捕鼠器的时间和出捕鼠器的时间计算出来,那就可以把一只进出捕鼠器时间当成一个集合,把各个集合求交集得到的就是最后可以捕到所有老鼠的时间范围,再取交集左边界时间就可以了. 千万要注意一点:老鼠不能在边界上被捕捉,表示之前没看…
Portal:http://codeforces.com/problemset/problem/687/A 二分图染色 好模板题 有SPJ 值得注意的是,因为C++的奇妙的运算机制 若在vector变量x.size()=0,则x.size()-1会溢出(此处坑了我3h) 这不禁让我想起了文明2里的甘地 #include<iostream> #include<algorithm> #include<set> #include<cstdio> #include&…
Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The travel agency “Four Russians” is offering the new service for their clients. Unlike other agencies that only suggest one-way…
Problem C. Painting CottagesTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The new cottage settlement is organized near the capital of Flatland. The construction company that is building the settl…
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly one lowercase English letter into s to make it a palindrome. A palindrome is a string that reads the same forward and backward. For…
Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The new cottage settlement is organized near the capital of Flatland. The construction company that is building the sett…
Problem F. Door LockTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description It was a beautiful night at Yekaterinburg, the sky was crystal clear with no clouds, and the view of the moon and the stars was…
Problem A. Alien Communication Masterclass Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Andrea is a famous science fiction writer, who runs masterclasses for her beloved readers. The most popular one is the…
Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Robots are becoming more and more popular. They are used nowadays not only in manufacturing plants, but also at home. One programmer wit…
Problem H. Horrible Truth Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description In a Famous TV Show “Find Out” there are n characters and only one Horrible Truth. To make the series breathtaking all way long, the sc…
Problem E. Explicit Formula Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Consider 10 Boolean variables x1, x2, x3, x4, x5, x6, x7, x8, x9, and x10. Consider all pairs and triplets of distinct variables amon…
Problem F "Folding" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100002 Description Bill is trying to compactly represent sequences of capital alphabetic characters from 'A' to 'Z' by folding repeating subsequences insid…
Problem J. TriatripTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The travel agency “Four Russians” is offering the new service for their clients. Unlike other agencies that only suggest one-way…
Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description Andrew is having a hard time preparing his 239-th contest for Petrozavodsk. This time the solution to the problem is based on Di…
Problem E. MinimaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description You are given an array x[1 . . . n] and a number m. For all i from 1 to n−m+ 1 find the minimum among x[i], x[i + 1], . . . , x[i +…
Problem D. Dinner ProblemTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description A group of k students from Cooking University living in the campus decided that each day of the semester one of them will p…
题目链接: http://codeforces.com/contest/706/problem/C 题目大意: n(2 ≤ n ≤ 100 000)个字符串(长度不超过100000),翻转费用为Ci(<=109),求所有字符串从上到下符合字典序从小到大的最小费用.无解输出-1. 题目思路: [动态规划] 每个字符串有2种状态,翻转或者不翻转,每次只与上一个字符串是否翻转有关,可以用DP. 费用很大,要用long long. 无解的时候我直接break了WA了好久. // //by coolxxx…
After several latest reforms many tourists are planning to visit Berland, and Berland people understood that it's an opportunity to earn money and changed their jobs to attract tourists. Petya, for example, left the IT corporation he had been working…
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the seco…
Problem A Lucky Year 题目传送门[here] 题目大意是说,只有一个数字非零的数是幸运的,给出一个数,求下一个幸运的数是多少. 这个幸运的数不是最高位的数字都是零,于是只跟最高位有关,只保留最高位,然后加一求差就是答案. Code /** * Codeforces * Problem#808A * Accepted * Time:15ms * Memory:0k */ #include<iostream> #include<cstdio> #include<…
Problem#A Carrot Cakes vjudge链接[here] (偷个懒,cf链接就不给了) 题目大意是说,烤面包,给出一段时间内可以考的面包数,建第二个炉子的时间,需要达到的面包数,问建炉子是否合理. 玄学 & 智商题,可能是因为我智商不够,所以在我决定休息的时候被hank掉了...(纠正一个错误,是fst掉的) 输NO的情况大概是当炉子建好后,考完第一波的时间,任务已经或刚好完成. Code /** * Codeforces * Problem#799A * Accepted *…
C. NP-Hard Problem time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very int…
1) Link to the problem: http://codeforces.com/contest/888/problem/C 2) Description: You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant if each substring of s with length at least k contains this character…
链接:https://codeforces.com/contest/1288/problem/D D. Minimax Problem 题意:给定n个数组,长度为m,从n中数组挑选两个数组,两个数组中的每一位取两者的最大值组成一个新的数组,新数组中的最小值记为c,所有组合中c的最大值 思路:题目中m的范围只有8,数组中元素的范围是1e9,显然m的范围非常特殊,似乎可以把数组用二进制的形式进行状态压缩,这里采用二分答案的方法.二分范围是数组元素最小值到最大值,每次check(mid)一遍,chec…