上一页 1 ··· 118 119 120 121 122 123 124 125 126 ··· 182 下一页
摘要: 题意:一些石头排成一条线,第一个和最后一个不能去掉,其余的共可以去掉m块,要使去掉后石头间距的最小值最大。分析:二分答案,对于每个固定的间距,先把离最后一块石头较近的都去掉,然后从左到右看,如果两个石头太近就把右面的去掉。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>usingnamespace std;#define maxn 50005int p, n, m, ans;int 阅读全文
posted @ 2011-07-02 19:57 undefined2024 阅读(1068) 评论(0) 推荐(0)
摘要: 题意:求a^b的所有约数的和对9901取余。分析:我们转化为a^b的所有质因子的等比数列的成积,例如100^1,转化为(1+2+4) * (1 + 5 + 25)。由于a^b的质因子与a的质因子相同,只是每个的数量是a的质因子的b倍。具体做法是先求所有素数,求a的所有质因子,对于每个质因子求num[i]*b+1项的等比数列。并求乘积。View Code #include #include #include #include #include usingnamespace std;#define maxn 10000#define w 9901int a, b;boolis[maxn];int 阅读全文
posted @ 2011-07-02 17:22 undefined2024 阅读(420) 评论(0) 推荐(0)
摘要: 题意:问区间[a,b]中,有多少个数化成二进制后,0比1多。分析:以110100为例,先计算小于100000的有多少个,c(5,2)+c(5,1)。还需要计算100000~110100之间的数量。再将除最高位的1之外的最高的1改为0,以保证后面组合时出现的所有数字小于110100,形如10****。后四位组合数c(4,2)+c(4,1)。再将下一个1变为0,变为1100**。如此依次将各个1变为0,并固定1前面的位,可以帮助我们计算出所有在100000~110100之间的数量。View Code #include <iostream>#include <cstdio># 阅读全文
posted @ 2011-07-02 15:31 undefined2024 阅读(1004) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 400int n, ball[maxn][maxn], f[maxn][maxn];int main(){ //freopen("t.txt", "r", stdin); scanf("%d", &n); for (int i = 1; i < 阅读全文
posted @ 2011-07-02 13:32 undefined2024 阅读(155) 评论(0) 推荐(0)
摘要: dpView Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 106struct Pearl{ int num, p;}pearl[maxn];int n, f[maxn];void input(){ scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d%d", &am 阅读全文
posted @ 2011-07-02 13:20 undefined2024 阅读(142) 评论(0) 推荐(0)
上一页 1 ··· 118 119 120 121 122 123 124 125 126 ··· 182 下一页