摘要: 关于巴什博奕: 只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。 网上有很多对先取完者胜的分析,先取完者负的分析很少,我通过网上流传的公式:(n-1)%(m+1)==0则后手胜利来分析一下 如果先取完的负,则显然胜利的一方需要把石子取到只剩一。设石子数量 阅读全文
posted @ 2016-07-23 21:57 GeniusYang 阅读(300) 评论(0) 推荐(1) 编辑
摘要: #include<cstdio> #define inf 0x3f3f3f3f const int maxn=10000; using namespace std; int n,m,q; int a[maxn+10]; int bs(int x){ int l=0,r=n-1; while(l<=r 阅读全文
posted @ 2016-06-22 22:15 GeniusYang 阅读(335) 评论(0) 推荐(0) 编辑
摘要: 输入方式值得学习 阅读全文
posted @ 2016-05-31 22:22 GeniusYang 阅读(225) 评论(0) 推荐(0) 编辑
摘要: /* 在n个刻度和他们的差里挑不超过7个刻度,0是固定的,最大的刻度肯定是最大值,然后剩下的dfs挑。 */ #include #define inf 0x3f3f3f3f const int maxn=1000000; using namespace std; int n,m,h,maxx,minx,icase,tar_size,a[100+10],ans[100+10],tar[10... 阅读全文
posted @ 2016-05-05 09:39 GeniusYang 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=691&pid=1003题意:找出一个字符串满足至少有k个不相同的字母的字串的个数可以注意到 如果 i到j 是满足条件的 则 i到j+1,j+2...n都是满足 阅读全文
posted @ 2016-04-27 22:52 GeniusYang 阅读(178) 评论(0) 推荐(0) 编辑
摘要: Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 42349 Accepted: 19917 Case Time Limit: 2000MS Description For the daily mil 阅读全文
posted @ 2016-02-28 22:05 GeniusYang 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 题意是有个三维的地图,从起点到终点的最短路径。用bfs做,不过这个题坑的地方在于,开三维数组你要搞清楚纬度的关系。a[i][j][h] i是层,j是行,h是列。然后坐标呢,又是列,行,层,所以如果要用sx,sy,sz,读取的时候要用 sz,sy,sx,的顺序读取。然后才能啊a[sx][sy][sz] 阅读全文
posted @ 2016-02-15 15:18 GeniusYang 阅读(338) 评论(0) 推荐(0) 编辑
摘要: 题意,一条数轴上,告诉你起点和终点,只能向前走1,向后走1,或者走到二倍的现在的位置,每次都耗时一分钟。问从起点到终点的最短时长。 简单地bfs #include <iostream> #include <algorithm> #include <cstdio> #include <map> #in 阅读全文
posted @ 2016-02-11 10:27 GeniusYang 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 素数环,简单的dfs,但这道题我有个小地方写错了半天发现不了。。就是flag数组的位置。一定要放在if里面,刚开始没注意,一不小心写到外面了。 #include <iostream> #include <algorithm> #include <cstdio> #include <map> #inc 阅读全文
posted @ 2016-02-09 20:37 GeniusYang 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 指针的链表实现方式是,当前节点的next指向下一个节点,用数组模拟就是 for(int i=next[0];i!=0;i=next[i]) i=next[i];就是一条链。 例题: 你有一个破损的键盘。键盘上的所有键都可以正常工作,但有时Home键或者End键会自动按下。你并不知道键盘存在这一问题, 阅读全文
posted @ 2016-02-01 22:27 GeniusYang 阅读(1558) 评论(0) 推荐(3) 编辑