![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
CodeForces
文章平均质量分 58
Kim0403
这个作者很懒,什么都没留下…
展开
-
Gym 101190F Foreign Postcards
题意和转移就不讲了,讲讲比较 迷 的一点吧。比赛结束之前,WA好多遍也没过,,我开始还以为状态转移不对,或者写搓了,但是队友坚持查错,最终发现了这些有趣的地方。目前只能怀疑和编译器有关系。这样写是正确的,可以AC:dp[0][0]=s[0]=='C'?1:0;这样写是不行的,27组测试数据处会WA:(s[0]=='C')?dp[0][0]=1:dp[0][0]=原创 2017-08-29 19:29:00 · 676 阅读 · 0 评论 -
CodeForces 547B Mike and Feet (区间dp)
思路和解释见代码注释。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define CPY(A, B) memcpy(A, B, siz原创 2016-07-13 10:59:28 · 313 阅读 · 0 评论 -
CodeForces 687C The Values You Can Make
给出n个数和K。 问n个数所有能构成k的子集合中所有的可能的和是多少?思路:dp[i][j]表示当前和是i能否构成j。如果dp[i][j]是可以的话,那么dp[i+m][j]和dp[i+m][j+m]都是可以得!(因为是子集合!!)最后枚举dp[K][i],把可以得放入ans数组或者vector输出即可! 不过我刚开始不明白dp[0][0]=1的实际意义。意义:空原创 2016-07-06 15:55:20 · 643 阅读 · 2 评论 -
CodeForces 166E Tetrahedron
这题是个规律题,我的好友们有用python跑出来规律的有用离散数学的关系矩阵计算出来的,与自己看出来的我用了dp…………int main() { LL ans=0; int n; cin>>n; for (int i=2; i<=n; ++i) { if (i%2==0) { ans= (ans+1) *3%MOD; } else { a原创 2016-07-14 15:43:44 · 452 阅读 · 0 评论 -
CodeForces 346A Alice and Bob
规律是最大数减n,奇数则Alice,偶数则Bob关键:最大数要先除以所有数的公约数例如:35 6 7可以如下Alice:1(7-6) 5 6 7Bob:1 2(7-5) 5 6 7Alice:1 2 3(5-2) 5 6 7Bob:1 2 3 4(6-2) 5 6 7轮到Alice了,但所有数两两绝对值都包含在内了,所以Alice输如果3原创 2016-07-19 15:52:18 · 395 阅读 · 0 评论 -
CodeForces 474D Flowers (dp)
dp[i]表示有i朵花时,有多少种吃法那么dp[i]=dp[i-1]+dp[i-k];dp[i-1]再吃朵红,dp[i-k]再吃k朵白#include#include#include#include#include#include#include#include#include#include#include#include#include#include#in原创 2016-07-13 10:15:53 · 344 阅读 · 0 评论 -
CodeForces 687B Remainders Game
一秒懵逼,数学不好,场上当然只能干瞪眼。顺便提一句,如果用cin输入,会超时的。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#de原创 2016-07-06 16:29:23 · 375 阅读 · 0 评论 -
CodeForces 589 J Cleaner Robot
这道题麻烦一些。就是一个扫地机器人,遇到障碍会右转,问最多会清扫多少地方。如果它进入一个胡同,会困在那里,所以要判断是不是被困住了。细节见代码。#include#include#include#include#include#include#include#include#include#include#include#include#include#includ原创 2016-08-16 19:28:44 · 496 阅读 · 0 评论 -
CodeForces 589 I Lottery
题意是给出一些数,问最少改变多少数字可以使它们出现频率相等。那么只统计超过平均数的那些,多出来的,肯定是需要被改变的。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#i原创 2016-08-16 18:58:00 · 384 阅读 · 0 评论 -
Codeforces Round #363 (Div. 2)B One Bomb
题意:3 4.*.......*..可以放一个炸弹,它炸整行整列,问能不能找到一个位置,一下炸掉所有'*''*'所在的位置也能放炸弹。#include#include#include#include#include#include#include#include#include#include#include#include#include#i原创 2016-07-20 14:51:03 · 277 阅读 · 0 评论 -
Codeforces Round #363 (Div. 2)A Launch of Collider
打完TC打CF,顺利多了………这道题是给出粒子个数和运动方向,以及它们的坐标,输出第一次对撞发生时过了几微秒。如果不可能发生碰撞输出“-1”4RLRL2 4 10 20输出1#include#include#include#include#include#include#include#include#include#include#include#i原创 2016-07-20 14:47:18 · 294 阅读 · 0 评论 -
CodeForces 547 B (区间dp)
思路详见代码#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define CPY(A, B) memcpy(A, B, sizeof(A原创 2016-07-25 16:47:32 · 382 阅读 · 0 评论 -
CodeForces 447C DZY Loves Sequences (dp 子序列)
因为change at most one number (change one number to any integer you want)所以找到左边递增的最大区间长度然后找到右边递增的最大区间长度如果最大长度就是n,那么说明原来就是升序排好了的。注意以下数据:51 2 2 3 4输出: 4有个细节见下方代码#include#include原创 2016-07-19 14:40:27 · 340 阅读 · 0 评论 -
CodeForces 518A Vitaly and Strings
给出s和t两个字符串,s字典序小于t,问是否可以找到字典序小于t,大于s的字符串,请输出其中一个本来想了些其他方法,都有问题,最后无奈………从s第一个字母开始,构造一个当前位置字母稍大的一个新字符串,后面全部置a,与t进行比较即可得出答案。#include#include#include#include#include#include#include#include#i原创 2016-07-06 22:40:09 · 3781 阅读 · 0 评论 -
CodeForces 589A Email Aliases
模拟题加上STL map的应用。开始竟然想用结构体来处理,后来觉得不仅会占大量空间,并且不好写……细节见代码。输入:6ICPC.@bmail.comp+con+test@BMAIL.COMP@bmail.coma@bmail.com.ruI.cpc@Bmail.Coma+b@bmail.com.ru输出:42 ICPC.@bmail.com I.原创 2016-08-11 21:59:33 · 565 阅读 · 0 评论 -
CodeForces 349B Color the Fence
先算出最多能有多少个数字,即最大能是多少位,然后再使这个数尽可能大,即最高位越大越好如75 4 3 2 2 2 3 4 5输出:766#include#include#include#include#include#include#include#include#include#include#include#include#include#inclu原创 2016-07-19 16:08:59 · 364 阅读 · 0 评论 -
CodeForces 288A Polo the Penguin and Strings
构造出前面都是a,b交替的字符串,最后一组在a,b之后添加c,d……这就是所求字符串。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#d原创 2016-07-25 20:56:33 · 858 阅读 · 0 评论 -
CodeForces 534B Covered Path
前半段肯定是加速,后半段可能要减速。有个有意思的解法#include #include #include #include #include #include #include #include #include #include using namespace std;int main() { int i,v1,v2,t,d,sum; while (~s原创 2016-07-25 22:02:53 · 326 阅读 · 0 评论 -
CodeForces 289B Polo the Penguin and Matrix
觉得和矩阵没什么关系,直接看成一个数列,从中位数开始,小的增加d,大的减小d,求操作多少次即可。如果取余不相等,那肯定不可能转换成同一个数字。#include#include#include#include#include#include#include#include#include#include#include#include#include#include原创 2016-07-25 20:54:13 · 1090 阅读 · 0 评论 -
CodeForces 288C Polo the Penguin and XOR operation
题意:给一个数 n,求0~n的一个排列,使得这个排列与0-n的对应异或之和最大。分析:两个数二进制数正好互补,异或就是最大的,比如,一个数是100,那么我们要找11,(都是二进制)就是这样找,而且两两正好配对,如果多了一个就是0。怎么找那另一个和它互补的数呢?用11...1 - 本身借鉴了MZH的代码#include#include#include#include#原创 2016-07-28 09:44:08 · 505 阅读 · 0 评论 -
CodeForces 131C The World is a Theatre 组合数
看过生活大爆炸的都知道,四男一女。所以就是男生的取法乘女生的取法#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define原创 2016-07-19 15:35:28 · 656 阅读 · 0 评论 -
CodeForces 548A Mike and Fax (回文)
#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define CPY(A, B) memcpy(A, B, sizeof(A))typed原创 2016-07-11 22:10:26 · 637 阅读 · 0 评论 -
CodeForces 474B Worms 二分
#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define CPY(A, B) memcpy(A, B, sizeof(A))typed原创 2016-07-13 10:13:05 · 480 阅读 · 0 评论 -
CodeForces 342C Cupboard and Balloons
往一个由半圆和长方形组成的盒子里放气球。重点考虑顶部那部分,放一个,两个,还是三个。计算一下能放下三个的极限情况就可以了。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#incl原创 2016-07-08 08:36:56 · 312 阅读 · 0 评论 -
CodeForces 670B(模拟)水题
Input 4 510 4 18 3The first robot says his identifier. After that the second robot says the identifier of the first robot and then says his own identifier. Then the third robot says the identifie原创 2016-05-27 18:20:39 · 584 阅读 · 0 评论 -
CodeForces 342A Xenia and Divisors
题目挺水,只有“1 2 4”,”1 2 6“,”1 3 6“这三种情况符合。所以就简单多了。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#inc原创 2016-07-08 08:41:25 · 752 阅读 · 0 评论 -
CodeForces 518B Tanya and Postcard
开始想着找到YAY的次数,用第一个字符串的长度减去它,就是剩的另一个结果。呃,显然这想法是错的。the letter in the given position has only the correct value but it is in the wrong case, then the girl says "WHOOPS".这才是第二个数据的正确求法。#include#inclu原创 2016-07-06 23:10:07 · 430 阅读 · 0 评论 -
CodeForces 339B Xenia and Ringroad
就是顺着环走,模拟一下,不能回头,所以遇到小的门牌号,就只能转一圈转回来#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#defi原创 2016-07-08 08:43:24 · 602 阅读 · 0 评论 -
CodeForces 681B Economy Game
好水,直接模拟爆#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define CPY(A, B) memcpy(A, B, sizeof原创 2016-07-08 21:42:58 · 358 阅读 · 0 评论 -
CodeForces 682B Alyona and Mex
一直都不懂,最后想明白了,让mex尽量大,1 3 5 7 9 这个数组变成1 2 3 4 5 此时mex最大是6。因为如果是1 2 3 4 9 ,那么mex必然是5,取不到最大了。所以1 3 3 3 6这组,变成1 2 3 3 4,mex就取5.然后代码如下:#include#include#include#include#include#include#include原创 2016-07-08 21:48:19 · 507 阅读 · 0 评论 -
CodeForces 548B Mike and Fun
#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define CPY(A, B) memcpy(A, B, sizeof(A))typed原创 2016-07-11 22:12:49 · 316 阅读 · 0 评论 -
CodeForces 474A Keyboard
跟紫书第三章那道uva题并不太一样,WA三次,最后才知道是要分成三组,呃#include #include char a[105];char b[3][11] = {"qwertyuiop","asdfghjkl;","zxcvbnm,./"};//uva10082是直接一个一维数组int main() { scanf ("%s", a); if (a[0] == 'R原创 2016-07-13 10:11:18 · 388 阅读 · 0 评论 -
CodeForces 166A Rank List
场上有点被逼急了,直接结构体加重载等于运算符。呃,简单直白,清晰明了#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define原创 2016-07-14 15:47:38 · 525 阅读 · 0 评论 -
CodeForces 166C Median
看了zzz的解法,场上有了思路也没时间做了。要找出来第一次位置和最后一次位置。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#def原创 2016-07-14 16:58:21 · 335 阅读 · 0 评论 -
CodeForces 540A Combination Lock
把密码锁调到目标位置,最少拨多少下。很水……#include #include #include #include #include #include #include #include #include #include #include #include #define LL long longusing namespace std;char s1[1005],原创 2016-07-25 21:02:33 · 355 阅读 · 0 评论 -
CodeForces 289A Polo the Penguin and Segments
The value of a set of segments that consists ofn segments [l1; r1], [l2; r2], ..., [ln; rn] is the number of integers x, such that there is integerj, for which the following inequality holds原创 2016-07-25 20:49:05 · 937 阅读 · 0 评论 -
CodeForces 688 B
水题,只要输出原字符串再倒序输出一遍即可,做法多样#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define CPY(A, B原创 2016-07-05 21:47:52 · 472 阅读 · 0 评论 -
CodeForces 688 A
输出包含‘0’字符的字符串,最大连续个数如下输入,第一第三第四行都含‘0’,但是第一行不连续,第三四行连续,所以该输出2Input4 511011111011010111111代码如下#include#include#include#include#include#include#include#include#include#原创 2016-07-05 21:54:12 · 331 阅读 · 0 评论 -
CodeForces 686 B
这道题被它输出示例坑了许久实际就是输出交换位置,完成排列。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define CPY(A,原创 2016-07-05 21:55:54 · 320 阅读 · 0 评论 -
CodeForces 682A Alyona and Numbers
开始竟然交了两重循环。果然超时。有规律可循,除以5就可以嘛。#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#define CPY(A原创 2016-07-08 21:40:53 · 374 阅读 · 0 评论