
codeforces
文章平均质量分 82
编码之夜
产品研发工程师
展开
-
Codeforces Round #297 (Div. 2)(模拟+字符串+排序)
A.题目链接:点击打开链接解题思路:大意就是说奇数位给小写字母,偶数位给大写字母,然后小写对应钥匙,大写对应门,问最少消耗几把钥匙能打开所有门。简单模拟即可,初始化一个英文字母数组,如果遇到小写字母,我们把相应的计数器++,遇到大写,如果它对应的数组值不为0,那么我们将其--,否则购买一把钥匙。完整代码:#include #include #incl原创 2015-03-30 09:38:07 · 647 阅读 · 0 评论 -
Yandex.Algorithm 2011 Qualification 2 A.(数学)
题目链接:http://codeforces.com/problemset/problem/82/A解题思路:对于1~5进行特殊处理,当n > 6时进行范围缩小。观察可得,每次的开始数字为5、10、20、50·····即为5*2^p。我们循环直到5*2^p > n 为止,其间每次更新n的值,即n -= 5 * 2 ^ p,并且p ++。最后只要判断n / 2^p即可。原创 2015-01-06 19:51:33 · 1175 阅读 · 0 评论 -
Codeforces Round #233 (Div. 2)A(构造)
题目链接:http://codeforces.com/contest/399/problem/A解题思路:构造出来即可,考虑p-k和p+k两个边界分别于1和n作比较,对左右符号特殊处理。完整代码:#include #include #include #include #include #include #include using namespace原创 2015-01-25 22:28:19 · 676 阅读 · 0 评论 -
CF#280 (Div. 2) C.(贪心)
C. Vanya and Examstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接:http://codeforces.com/contest/492/problem/原创 2014-12-02 10:52:24 · 539 阅读 · 0 评论 -
Codeforces Round #282 (Div. 2) B.(数学)
题目链接:http://codeforces.com/contest/495/problem/B解题思路:求a % x == b,可以得知(a - b) % x == 0,x > b。当a == b时,一定有无穷多解;当a 完整代码:#include #include #include #include #include #include #incl原创 2015-01-07 17:47:03 · 558 阅读 · 0 评论 -
Codeforces Round #270 A.(素数打表)
题目链接:http://codeforces.com/problemset/problem/472/A解题思路:打出素数表,cnt从4开始,如果cnt和n - cnt都不是素数的话,输出即可,否则cnt ++完整代码:#include #include #include #include #include #include #include #incl原创 2015-01-06 19:52:03 · 615 阅读 · 0 评论 -
Codeforces Round #195 (Div. 2) A.(数学枚举)
题目链接:http://codeforces.com/problemset/problem/336/A解题思路:枚举各个点在第一、二、三、四象限的这四种情况,每次求出对应的x1和y2坐标即可,x2和y1一直是0。最后注意下输出时要求x1 完整代码:#include #include #include #include #include #include原创 2015-01-06 19:53:23 · 514 阅读 · 0 评论 -
Codeforces Round #188 (Div. 2) A(数学划分)
题目链接:http://codeforces.com/contest/318/problem/A解题思路:把n分奇偶判断。如果n是偶数,那么判断k是否小于n/2,满足的话输出2 * k - 1,否则要把 k 更新为k -= n / 2,再输出2 * k;同理,如果n是奇数,那么判断k是否小于n /2 + 1,满足的话输出2 * k - 1,否则把k更新为k -= n / 2 +原创 2015-01-06 19:52:57 · 534 阅读 · 0 评论 -
CF#280 (Div. 2) A.(找规律)
A. Vanya and Cubestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接:http://codeforces.com/contest/492/problem/原创 2014-12-02 10:39:30 · 485 阅读 · 0 评论 -
CF#278 (Div. 2) A.(暴力枚举)
A. Giga Towertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiga Tower is the tallest and deepest building原创 2014-11-22 10:51:23 · 1054 阅读 · 0 评论 -
CF#274 (Div. 2) C.(贪心+排序)
C. Examstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputStudent Valera is an undergraduate student at the University.原创 2014-10-21 00:13:43 · 619 阅读 · 0 评论 -
CF #262 (Div. 2)B
B. Little Dima and Equationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Dima misbehaved durin原创 2014-08-27 07:45:17 · 619 阅读 · 0 评论 -
CF#275 (Div. 2) C(数学构造)
C. Diverse Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPermutation p is an ordered set of in原创 2014-10-29 09:23:33 · 1035 阅读 · 0 评论 -
CF#275 (Div. 2) A.(暴力)
A. Counterexampletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接:http://codeforces.com/contest/483/problem/A原创 2014-10-29 08:21:37 · 1634 阅读 · 0 评论 -
CF#277.5 (Div. 2) A.(技巧题,类似动规)
A. SwapSorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接:http://codeforces.com/contest/489/problem/A原创 2014-11-19 12:54:58 · 700 阅读 · 0 评论 -
CF #273 (Div. 2) A.(简单规律)
A. Initial Bettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are five people playing a game called "Generosity原创 2014-10-17 12:31:13 · 881 阅读 · 0 评论 -
CF #278 (Div. 2) B.(暴力枚举+推导公式+数学构造)
B. Candy Boxestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接:http://codeforces.com/contest/488/problem/B原创 2014-11-22 12:16:00 · 754 阅读 · 0 评论 -
CF#272 (Div. 2) B.(dfs)
B. Dreamoon and WiFitime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接:Dreamoon is standing at the position 0原创 2014-10-21 00:55:16 · 628 阅读 · 0 评论 -
CF#274 (Div. 2) B.(暴力模拟)
B. Towerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you know, all the kids in Berland love playing with cubes原创 2014-10-20 22:39:50 · 613 阅读 · 0 评论 -
CF#280 (Div. 2) B.(益智)
B. Vanya and Lanternstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接:http://codeforces.com/contest/492/probl原创 2014-12-02 10:45:29 · 513 阅读 · 0 评论 -
Codeforces Round #282 (Div. 2) A.(乘法原理)
题目链接:http://codeforces.com/contest/495/problem/A解题思路:数学技巧,分析每个数字通过增加一些边,使得它变成另一个数字。把0~9每个数字可以形成数字的种数存放进数组,对应a[ n ] * a[ m ]即可。乘法原理。0可以构成0和8;1可以构成1、7、3、4、8、9、0;2可以构成2、8;3可以构成3、9、8;4原创 2015-01-07 14:00:09 · 563 阅读 · 0 评论 -
Codeforces Round #287 (Div. 2)B(几何)
题目链接:http://codeforces.com/contest/507/problem/B解题思路:两个圆心之间直线最短,求出圆心距,对其用ceil向上取整,注意中间计算时可能会溢出,开成long long。如果d能整出2*r,那么输出商即可,否则输出商+1。相交时只需要以交点为中心,再旋转一次即可。完整代码:#include #include #incl原创 2015-01-24 20:39:04 · 704 阅读 · 0 评论 -
Codeforces Round #236 (Div. 2)A(贪心、数学)
题目链接:http://codeforces.com/contest/402/problem/A解题思路:一路贪心,把条件判断好即可。完整代码:#include #include #include #include #include #include #include using namespace std;typedef long long LL;原创 2015-01-25 21:58:52 · 584 阅读 · 0 评论 -
Codeforces Round #182 (Div. 2)A(水题)
题目链接:http://codeforces.com/contest/302/problem/A解题思路:只要通过重新排列使区间内和为0即是1,否则是0.完整代码:#include #include #include #include #include #include #include #include using namespace std;原创 2015-01-25 23:40:04 · 670 阅读 · 0 评论 -
Codeforces Round #281 (Div. 2)A(构造+暴力模拟)
题目链接:http://codeforces.com/problemset/problem/493/A解题思路:暴力的判断,分三种情况去判断即可。注意如果之前已经被罚下场后,那么在后面的罚下情况不应该算在输出结果内。完整代码:#include #include #include #include #include #include #include u原创 2015-01-26 00:20:24 · 600 阅读 · 0 评论 -
Codeforces Round #247 (Div. 2)A(构造)
题目链接:http://codeforces.com/contest/431/problem/A解题思路:构造出来即可。完整代码:#include #include #include #include #include #include #include using namespace std;typedef long long LL;const原创 2015-01-25 22:08:53 · 494 阅读 · 0 评论 -
Codeforces Round #287 (Div. 2)A(排序)
题目链接:http://codeforces.com/contest/507/problem/A解题思路:排个序就出来了。完整代码:#include #include #include #include #include #include #include using namespace std;typedef long long LL;const原创 2015-01-24 19:45:49 · 671 阅读 · 0 评论 -
MemSQL Start[c]UP 2.0 - Round 1A(构造)
题目链接:http://codeforces.com/problemset/problem/452/A解题思路:打个表暴力查找匹配。完整代码:#include #include #include #include #include #include #include using namespace std;typedef long long LL原创 2015-01-26 00:33:21 · 673 阅读 · 0 评论 -
Codeforces#295(Div.2)A、B(模拟+BFS)
解题报告链接:点击打开链接原创 2015-03-03 19:12:51 · 704 阅读 · 0 评论 -
Good Bye 2014 C.(栈模拟)
题目链接:http://codeforces.com/contest/500/problem/C解题思路:本题过程完全可以用栈模拟来做,难点在于初始栈的构造。题目要求求出移动的总的最小重量,我们首先就构造初始栈,构造方法就是观察b数组里的值,把前n个不同元素入栈,注意是不同的元素!!!如果发现b数组扫完了,但是栈内元素不满n个,那么也不用再考虑其他元素了。具体证明略,此处想想就出来原创 2014-12-31 08:43:57 · 597 阅读 · 0 评论 -
Good Bye 2014 A.(模拟)
题目链接:http://codeforces.com/contest/500/problem/A解题思路:模拟过程,sum初始值为1,如果整个表都扫遍了都扫不到t,输出NO。其实不一定扫遍,感觉只要扫到大于 t 即可,因为其中没有负数。完整代码:#include #include #include #include #include #include #原创 2014-12-31 09:02:46 · 510 阅读 · 0 评论 -
Codeforces Round #285 (Div. 2)A.(手速)
题目链接:http://codeforces.com/contest/501/problem/A解题思路:手速题·····直接套题目里的公式,四分钟AC。完整代码:#include #include #include #include #include #include #include #include #include #include #i原创 2015-01-13 16:29:32 · 501 阅读 · 0 评论 -
Codeforces Round #285 (Div. 2)B.(字符串连接)
题目链接:http://codeforces.com/contest/501/problem/B解题思路:分别用a、b两个字符串数组来存储第一列和第二列的字符串。接下来进行O(n^2)遍历,初始化标记数组vis为0。如果vis[ i ] == 0,那么对其b[ i ]进行更新。这里更新仔细想想有个很有趣的问题,就是字符串是严格按时间排序的,所以不会出现字符串乱接这种情况。最后开原创 2015-01-14 10:01:07 · 510 阅读 · 0 评论 -
CF#284 (Div. 2) C.(几何规律)
题目链接:http://codeforces.com/contest/499/problem/C解题思路:把两个点的坐标分别带入方程组,如果最后两个值相乘为负,即异号,计数器++。其中有一个有趣的现象,从A到B的最短步数,可以变化为求A和B之间夹了多少条直线,那么最后只要求出直线数,即可求出最小步数。如果一条直线夹在A和B中间,那么把A和B的坐标带入后,所得值相乘一定为负。数据原创 2014-12-25 12:32:10 · 678 阅读 · 0 评论 -
CF#284 (Div. 2) B.(暴力)
题目链接:http://codeforces.com/contest/499/problem/B解题思路:开一个is变量记录每组单词最后应该输出哪个。最后每次把原来的数组暴力扫一遍即可。完整代码:#include #include #include #include #include #include #include #include #inclu原创 2014-12-25 10:29:13 · 624 阅读 · 0 评论 -
CF #284 (Div. 2) A.(模拟)
题目链接:http://codeforces.com/contest/499/problem/A解题思路:模拟过程,如果step + x 完整代码:#include #include #include #include #include #include #include #include #include #include #include原创 2014-12-25 10:32:26 · 430 阅读 · 0 评论 -
CF #283 (Div. 2) B.(字符串好多坑)
题目链接:http://codeforces.com/contest/496/problem/B解题思路:首先明确可以暴力,写一个add函数和shift函数。然后给一个循环值cnt,做cnt次循环即可,每次取两种情况的最小值入字符串数组,最后排下序,输出最小的字符串。这个cnt很不好控制,我也是WA了几次才估计出来的·······接下来说说奇葩的数据:Input:原创 2014-12-25 21:17:20 · 756 阅读 · 0 评论 -
Codeforces Round #286 (Div. 2) A.(回文串暴力)
题目链接:http://codeforces.com/contest/505/problem/A解题思路:暴力求解,对于每一个位置,都用a到z进行插入,如果有符合条件的,直接输出。否则输出NA完整代码://#include #include #include #include #include #include #include #include #原创 2015-01-19 12:56:32 · 672 阅读 · 0 评论 -
Good Bye 2014 B.(Floyd+暴力)
题目链接:http://codeforces.com/contest/500/problem/B解题思路:用Floyd的方法把矩阵里所有传递关系都求出来,在用O(n^2)的暴力求解。规则就是每次找能交换的,并且最小的交换到前面,这样能保证最优解。完整代码://#include #include #include #include #include #inc原创 2015-01-18 10:52:32 · 537 阅读 · 0 评论 -
CF#277 (Div. 2) A.(找规律)
A. Calculating Functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接:http://codeforces.com/contest/486/pro原创 2014-11-12 20:11:37 · 869 阅读 · 0 评论