摘要: 题意:给出膨胀指数,加热温度,杆子的原长度,问加热后的杆子两端点位置不变,弯曲成弧,圆心的位置。分析:二分答案,二分查找圆心位置,根据圆心位置计算出弧长与原弧长比较,不知道为什么wa那么多次。View Code #include #include #include #include #include usingnamespace std;#define eps 1.0e-8double c, l1, n;double cal(double b){ double a = l1 /2; double d = sqrt(a * a + b * b); double h = a * ... 阅读全文
posted @ 2011-07-02 21:22 undefined2024 阅读(401) 评论(0) 推荐(0)
摘要: 题意:一些石头排成一条线,第一个和最后一个不能去掉,其余的共可以去掉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 阅读(156) 评论(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)
摘要: 题意:问母串中至少去掉多少个字母才能是刚好由单词表中的一些单词连接而成的。分析:dp,f[i]表示母串从第i位起始的后缀所对应的最少去掉字母数。f[i]有两种选择f[i + 1] + 1或者f[i + num] + num - strlen(word[j])。其中num是从第i位开始匹配word[j]所需要的母串从i位起始的后缀的前缀的长度。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>usingnamespace std;#de 阅读全文
posted @ 2011-07-02 12:55 undefined2024 阅读(1002) 评论(1) 推荐(1)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int n, m, a[10], la, ans;bool reject;bool split[10], ansplit[10];void work(){ la = 0; while (n > 0) { a[la] = n % 10; n /= 10; la++; } for (int i = 0; i < la / 2; i+ 阅读全文
posted @ 2011-07-02 09:55 undefined2024 阅读(381) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 105struct Node{ int va, vb, step, pre, opr;} q[maxn * maxn];int a, b, c, l, r;bool vis[maxn][maxn];int stk[maxn * maxn], top;void make(int va, int vb, int opr 阅读全文
posted @ 2011-07-02 08:57 undefined2024 阅读(162) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 105struct Node{ int va, vb, step, pre, opr;} q[maxn * maxn];int a, b, c, l, r;bool vis[maxn][maxn];int stk[maxn * maxn], top;void make(int va, int vb, int opr 阅读全文
posted @ 2011-07-02 08:42 undefined2024 阅读(124) 评论(0) 推荐(0)