摘要:
题意:对于n堆石子,每堆若干个,两人轮流操作,每次操作分两步,第一步从某堆中去掉至少一个,第二步(可省略)把该堆剩余石子的一部分分给其它的某些堆。最后谁无子可取即输。分析:首先我们考虑两堆相等的情况,一定是谁取谁输,因为对方永远可以做对称的操作。对于四堆,1、2堆相等,3、4堆相等的情况,一定也是先手输,后手也只需要做对称的操作(在先手取石子的对称堆中取相同多的石子,并把和先手等量的石子分给先手分配给的堆的对称堆。(若先手在3堆取,并分给1堆,那后手就在4堆取,分给2堆)。也就是说对于任意的一对一对相等的情况来说,一定是后手必胜。我们接下来来证明除上述情况外,所有情况都是先手必胜。因为任何一种 阅读全文
posted @ 2011-07-09 19:35
undefined2024
阅读(1235)
评论(0)
推荐(1)
摘要:
题意:一个国际象棋棋盘,有一个国王,和若干个骑士(马)。问要把他们都挪到一个格需要至少多少步。(国王如果和某骑士在同一个格则两者可以同时以骑士的方式移动且只记做一步)分析:暴力枚举,跳马距离可先用floyd求。枚举终点,枚举国王上马地点,枚举国王要遇到的骑士。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>usingnamespace std;#define inf 0x3f3f3f3f#define maxn 70struct P 阅读全文
posted @ 2011-07-09 17:46
undefined2024
阅读(725)
评论(0)
推荐(0)
摘要:
题意:从某年某月某天开始两个人轮流开始将日期推进,推进方法有两种,1.推进到第二天 2.推进到下个月的这一天。谁到达2001.11.4谁赢,谁超过了谁输。分析:np问题,我们设月号加日号等于d,对于第二种推进方式,会改变d的奇偶性。(因为月的奇偶变了,日的奇偶没变,和的奇偶就变了)。对于第一种推进方式,如果推进后还在同一个月份,那么会改变d的奇偶性。(因为月的奇偶没变,日的变了,和的奇偶就变了)。第一种推进方式,跨月份的时候,有些会改变,有些不会改变。有31天、29天的月份会变,30天、28天的不会变,其中对于d为偶的情况(2月28,4、6月30)可以利用第二中方式变为奇。由此可见对于绝大部分 阅读全文
posted @ 2011-07-09 15:43
undefined2024
阅读(560)
评论(0)
推荐(0)
摘要:
暴力就可以过View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 106struct Device{ int p, b;} dev[maxn][maxn];int s, e, n;int maxb[maxn], minb[maxn], num[maxn];void input(){ scanf("%d", &n); for (int i = 0; 阅读全文
posted @ 2011-07-09 14:42
undefined2024
阅读(1305)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("t.txt", "r", stdin); int a, b; scanf("%d%d", &a, &b); if (a == 0 && b == 0) { printf("Impossible\ 阅读全文
posted @ 2011-07-09 14:22
undefined2024
阅读(183)
评论(0)
推荐(0)
摘要:
题意:给定一个立方体的体积,使其表面积最小,求长宽高(长宽高均为整数)分析:先求其所有因子,然后暴力枚举3条棱的长度,更新最小面积。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>usingnamespace std;#define maxn 10000longlong f[maxn];int main(){ //freopen("t.txt", "r", stdin);int t; scan 阅读全文
posted @ 2011-07-09 14:21
undefined2024
阅读(409)
评论(0)
推荐(0)
摘要:
有两种理解方法。虽然对于相同的数据有不同的输出,但据说都能过。但是我的其中一个没过。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 30005int n, m;int f[maxn], sum[maxn];int main(){ //freopen("t.txt", "r", 阅读全文
posted @ 2011-07-09 10:40
undefined2024
阅读(335)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("t.txt", "r", stdin); int a1, a2, b1, b2, p; scanf("%d%d%d%d%d", &a1, &a2, &b1, &b2, &p); if ((a1 & 阅读全文
posted @ 2011-07-09 09:50
undefined2024
阅读(288)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("t.txt", "r", stdin); int t; scanf("%d", &t); while (t--) { int h, m; scanf("%d:%d", &h, &m); if 阅读全文
posted @ 2011-07-09 09:34
undefined2024
阅读(173)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int t;char weekday[10][20] = { "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday 阅读全文
posted @ 2011-07-09 09:25
undefined2024
阅读(216)
评论(0)
推荐(0)