自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(41)
  • 收藏
  • 关注

转载 Codeforces Round #226 (Div. 2)B. Bear and Strings

/*  题意就是要找到包含“bear”的子串,计算出个数,需要注意的地方就是不要计算重复。 */ 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #define maxn 5005 5 6 char str[maxn]; 7 int p...

2019-09-25 17:26:50 130

转载 HDU(2955)Robberies (0-1背包)

/*    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2955    题意:Roy想要抢劫银行,每家银行多有一定的金额和被抓到的概率,知道Roy被抓的最       大概率P,求Roy在被抓的情况下,抢劫最多。    分析:考虑其反面。被抓概率可以转换成安全概率,Roy的安全概率大于1-P时都是安全的。抢劫的金   ...

2019-09-25 17:26:47 109

转载 HOJ (1042) 整数划分

题目:http://acm.hit.edu.cn/hoj/problem/view?id=1402 整数划分问题 Submitted: 886,Accepted: 374 整数划分是一个经典的问题。希望这道题会对你的组合数学的解题能力有所帮助。 Input 每组输入是两个整数n和k。(1 <= n <= 50, 1 <= k &...

2019-09-25 17:26:45 145

转载 HDU(3374) (KMP + 最小表示法)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=3374最小表示法:http://tobyaa.blog.163.com/blog/static/30248591201261604349913/#include <stdio.h> #include <string.h> #include <iostream&...

2019-09-25 17:26:42 116

转载 FZU Problem 1926 填空(KMP好题一枚,确实好)

题目:http://acm.fzu.edu.cn/problem.php?pid=1926 #include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <...

2019-09-25 17:26:40 105

转载 POJ(2761)Feed the dogs (树状数组+离散化+贪心)

#include <iostream> #include <algorithm> #include <stdio.h> #include <string> #include <string.h> #include <stdlib.h> #include <math.h> #include...

2019-09-25 17:26:37 115

转载 POJ(2481)Cows 树状数组

#include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <math.h> #include <fstream> #include ...

2019-09-25 17:26:35 72

转载 ZOJ(1004)Anagrams by Stack (DFS+stack)

#include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <math.h> #include <fstream> #include ...

2019-09-25 17:26:32 181

转载 ZOJ(1711)Sum It Up (DFS+剪枝+去重复)

#include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <math.h> #include <fstream> #include ...

2019-09-25 17:26:31 85

转载 HDU(1849)Rabbit and Grass(博弈)

尼姆博弈,并且SG(n) = n #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <math.h> #include <stdlib.h> #include <...

2019-09-25 17:26:28 96

转载 题目1553:时钟

题目:http://ac.jobdu.com/problem.php?pid=1553 /*   分别算出时针和分针的度数,做差之后分几种情况讨论,(-360,-180),[-180,0),[0,180],(180,360). */ #include <stdio.h> int main(){ int h,m; while (~sca...

2019-09-25 17:26:25 108

转载 HDU(1517)A Multiplication Game(博弈)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1517 题意:2 个人玩游戏,从 1 开始,轮流对数进行累乘,直到超过一个指定的值。 [2,9] Stan wins. [10,18] Ollie wins. [19,162]Stan wins. [162,324]Ollie wins. ... ... #includ...

2019-09-25 17:26:24 81

转载 HDU(1851) A Simple Game (博弈)

任给N堆石子,两人轮流从任一堆中任取(每次只能取自一堆),规定每方每次最多取K颗,取最后一颗石子的一方获胜.问先取的人如何获胜? 巴什博奕和尼姆博弈的综合。 令Bi=Mi mod(Li+1) 定义T‘=B1 xor B2 xor ... xor Bn 如果T‘=0 那么没有获胜可能,先取者必败 如果T’>0 那么必然存在取的方法,使得T‘=0,先取者有获胜的方法 假设对...

2019-09-25 17:26:23 89

转载 Codeforces Round #226 (Div. 2)C. Bear and Prime Numbers

/* 可以在筛选质数的同时,算出每组数据中能被各个质数整除的个数, 然后算出[0,s]的个数 [l,r] 的个数即为[0,r]的个数减去[0,l]个数。 */ #include <stdio.h> #include <iostream> #include <string.h> #define maxn 1000001...

2019-09-25 17:26:23 87

转载 Codeforces Round #226 (Div. 2)A. Bear and Raspberry

/*    贪心的找到相邻两项差的最大值,再减去c,结果若是负数答案为0. */ 1 #include <stdio.h> 2 #define maxn 105 3 int num[maxn]; 4 int main() 5 { 6 int n,c; 7 while(~scanf("%d%d",&n,&c)) ...

2019-09-25 17:26:21 86

转载 HDU(4522) 湫湫系列故事——过年回家

题目:http://acm.hdu.edu.cn/showproblem.php?pid=4522 建两个图,分别用dijstra。 #include<stdio.h> #include<iostream> #include<string.h> #include<math.h> #include<string> ...

2019-09-25 17:26:19 117

转载 HDU(2897)邂逅明下

巴什博奕的变形。 只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取p个,最多取q个。最后取光者得输。显然,如果n=r*(p+q)+s , 即s = n%(p+q).  # n%(p+q) == 0     先手一定赢,假设先手第一次拿q个,接着每次不管后手拿多少个,假设后手拿k个,先手都可以拿p+q-k     个,所以最后一定剩下p个给后手,所以先手必...

2019-09-25 17:26:19 96

转载 HDU(2149)Public Sale 博弈

典型的巴什博奕。 #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <set> using namespace std; int main() { int m,n; ...

2019-09-25 17:26:18 74

转载 HDU(1847)Good Luck in CET-4 Everybody!

利用PN分析求解此题。递推下去会发现3和3的倍数都是P点。 #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <set> using namespace std; int main()...

2019-09-25 17:26:16 163

转载 Codeforces Round #106 (Div. 2) 149/E E. Martian Strings

/*  http://codeforces.com/problemset/problem/149/E  KMP结合动态规划的思想,正向匹配一边,l[]数组保存的是对于匹配串的每一个位置在模式串能匹配的最左边,也就是首次匹配的位置  逆序再匹配一次,逆向信息保存r[]数组。  再枚举l[i]+r[len-i]*/#include<stdio.h> #include<...

2019-09-25 17:26:16 123

转载 HDU(1525)Euclid's Game

#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <set> using namespace std; int main() { int a,b; while(sca...

2019-09-25 17:26:14 70

转载 FZU Problem 2030 括号问题

/*  对于小数据用这dfs,大数据就用递推的思想。*/#include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <math.h> #includ...

2019-09-25 17:26:14 75

转载 Codeforces Round #183 (Div. 2) B. Calendar

题目:http://codeforces.com/contest/304/problem/B#include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <m...

2019-09-25 17:26:13 73

转载 [USACO 1.5.3]特殊的质数肋骨

题目:http://www.acmore.net/problem.php?cid=1013&pid=5 #include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #in...

2019-09-25 17:26:12 144

转载 zoj(1586)最小生成树

题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1586#include <cstdlib> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm...

2019-09-25 17:26:11 89

转载 hdu(4267)A Simple Problem with Integers(三维树状数组)

  这道题拿过来感觉很蒙 , 因为以前做的都是点更新询问区间 , 或是区间更新询问点 , 这道题是在[a,b]区间内隔k个数更新一次((i - a) % k == 0即i%k==a%k),对于树状数组来说按照一维的方式定义, 后面在加上两维 c[i][k][i%k] (a<=i<=b), 相当于在一维c[i]每个节点加入了一些信息,来记录每次更新,询问时候再加上原数...

2019-09-25 17:26:10 150

转载 NEU(1262: ASCII Sequence II)动态规划

http://acm.neu.edu.cn/hustoj/problem.php?id=1262 #include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include &...

2019-09-25 17:26:09 112

转载 zoj(2110)Tempter of the Bone(DFS+奇偶剪枝)

剪枝很重要,可走的格数小于时间则减去,然后就是奇偶性剪枝可以把map看成这样: 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 从为 0 的格子走一步,必然走向为 1 的格子 从为 1 的格子走一步,必然走向为 0 的格子 即: 0 ->1或1->0 必然是奇数步 0->0 走1->1 必...

2019-09-25 17:26:07 90

转载 HDU(1867)A + B for you again (KMP)

#include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <math.h> #include <vector> #include &...

2019-09-25 17:26:07 61

转载 HDU(1536)S-Nim (博弈)

这道题是对SG函数的考查 #include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <math.h> #include <vector&g...

2019-09-25 17:26:05 110

转载 HDU(2188)悼念512汶川大地震遇难同胞——选拔志愿者

/*  典型的巴什博奕。*/#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <math.h> #include <stdlib.h> #include <queue&...

2019-09-25 17:26:04 131

转载 csust 1467: 数学(扩展欧几里得)

http://www.acmore.net/problem.php?id=1467 根据朴素的欧几里德原理有 gcd(a,b)=gcd(b,a mod b); 则:ax1+by1=bx2+(a mod b)y2; 即:ax1+by1=bx2+(a-[a/b]*b)y2=ay2+bx2-(a/b)*by2; 根据恒等定理得:x1=y2; y1=x2-[a/b]*y2; 本题直接利...

2019-09-25 17:26:04 117

转载 HDU(1850) Being a Good Boy in Spring Festival (博弈)

/* 每一堆的数值与ans相异或,所得的结果就是这一堆可以取的数量。 但是,如要这一堆数量没有这么多,就不可以这么取 异或运算本身就是互逆运算 */ #include <iostream> using namespace std; int value[101]; int main (){ int n,sum,count,i; w...

2019-09-25 17:26:02 76

转载 hdu (2852) KiKi's K-Number

二分+树状数组动态的寻找比a大k的数 #include <stdio.h> #include <iostream> #include <string> #include <string.h> #include <algorithm> #include <stdlib.h> #include <...

2019-09-25 17:26:02 73

转载 1504: ZZ的橱柜(长沙理工oj)

http://www.acmore.net/problem.php?id=1504 利用优先队列,转化成O(m)的复杂度。 #include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm&g...

2019-09-25 17:26:01 122

转载 Codeforces Round #117 (Div. 2) D. Common Divisors

http://www.codeforces.com/problemset/problem/182/D 利用到KMP的周期性。现寻找最小周期,再进行扩充。 #include <iostream> #include <stdio.h> #include <string> #include <string.h> #include ...

2019-09-25 17:26:00 94

转载 hdu(4339)树状数组+二分查找

/*     s1[i]与s2[i]匹配,树状数组i位置更新1,否则更新0。*/#include<stdio.h> #include<string.h> #include<algorithm> #include<iostream> using namespace std; const int maxn = 100000...

2019-09-25 17:25:58 97

转载 ZOJ(1649)Rescue

#include <iostream> #include <stdio.h> #include <string> #include <string.h> #include <algorithm> #include <stdlib.h> #include <math.h> #include...

2019-09-25 17:25:58 145

转载 poj(2185) Milking Grid (很好的kmp题目)

http://poj.org/problem?id=2185 题意:给你一个字符矩阵,求出它的最小覆盖子矩阵,即使得这个子矩阵的无限复制扩张之后的矩阵,能包含原来的矩阵。即二维的最小覆盖子串。 思路:KMP很好的一道题。首先易证:最小覆盖子矩阵一定靠左上角。那么,我们考虑求出每一行的最小重复串长度,所有行的最小重复串的长度的lcm就是最小重复子矩阵的宽。然后我们对列也做相同的...

2019-09-25 17:25:56 88

转载 HDU(2509) Be the Winner /HDU(1907) John (Nim 博弈)

/*       尼姆博奕(Nimm Game):有三堆各若干个物品,两个人轮流从某一堆取任意多的物品,规定每次至少取一个,多者不限,最后取光者得胜。  这种情况最有意思,它与二进制有密切关系,我们用(a,b,c)表示某种局势,首先(0,0,0)显然是奇异局势,无论谁面对奇异局势,都必然失败。第二  种奇异局势是(0,n,n),只要与对手拿走一样多的物品,最后都将导致(0,...

2019-09-25 17:25:55 115

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除