摘要:
和1011拼木棒差不多,但是直接拿那个程序居然错了,就是在拼新的木棒的时候忘记判断第一个加入其中的小木棒是不是会超出要拼的木棒的长度。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;const int maxn = 64;int t, n, stick[maxn], each, ok, total, num;bool used[maxn];v 阅读全文
posted @ 2011-05-24 19:30
undefined2024
阅读(472)
评论(0)
推荐(0)
摘要:
树状数组,注意树状数组范围View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxm 32005int n, ans[maxm];int ar[maxm];int lowb(int t){ return t & (-t);}void add(int i, int v){ for (; i < maxm; ar[i] += v, i += lowb(i)) ;}int 阅读全文
posted @ 2011-05-24 18:59
undefined2024
阅读(252)
评论(0)
推荐(0)
摘要:
题意:给定两个数,两个人轮流操作,先把其中一个数变为0的人赢。这种操作是用把大数变为大数减小数的若干倍的差(不能小于0)。问谁能赢。分析:谁先抢到关键态,谁就能赢。关键态就是大数是小数的二倍多。一个人一旦抢到了关键态,就可以直接操控下面一连串的非关键态的次序,非关键态相当于每个人进行的都是a%b,所以是交替进行a%b和b%a。也就是说这个究竟自己是a%b还是b%a在非关键态中,自己是无法决定的。只能由上一个关键态的操控者决定。这样获胜的方法就是,一个人一旦取得关键态,就算准次序,让自己获得下一个关键态。直至获胜。View Code #include <iostream>#inclu 阅读全文
posted @ 2011-05-24 18:31
undefined2024
阅读(610)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 100int f1[maxn], f2[maxn], count1, count2;void make(int x, char *st){ if (strcmp(st, "too high") == 0) f1[count1++] = x; else f2[count2++] = x;}bool 阅读全文
posted @ 2011-05-24 18:09
undefined2024
阅读(255)
评论(0)
推荐(0)