上一页 1 ··· 103 104 105 106 107 108 109 110 111 ··· 182 下一页
摘要: 题意:给定一个矩阵,从左上角到右下角,使走过的路径中数字的最大值最小值之差最小,问差最小是多少。分析:首先不能用bfs,priority_queue以下两组数据可以说明问题。有时候不能先扩展最优的。25 61 135 6 11 3 51 7 1正确的方法是二分这个差值a,对于每个二分结果枚举范围d~d+a,然后进行bfs,只有矩阵上的数字在d到d+a之间的格子才可以走。看能否到达终点。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring> 阅读全文
posted @ 2011-07-20 11:05 undefined2024 阅读(382) 评论(0) 推荐(1)
摘要: 题意:梅森数(Mersenne number)是指形如2^p-1的正整数,其中指数p是素数,常记为Mp 。若Mp是素数,则称为梅森素数(Mersenne prime)。本题要求梅森合数。分析:打表计算,求出所有的梅森数,并暴力分解,看是否为合数。View Code /*#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;bool isprime(int a){ for (i 阅读全文
posted @ 2011-07-20 08:19 undefined2024 阅读(302) 评论(0) 推荐(0)
摘要: 题意:给定两个圆,求相交面积。分析:把两个弓形面积相加,可转化为分别求两个扇形面积,相加后减去两个三角形面积。两个三角形可以合并为一个四边形,而四边形可以根据两个圆心的连线分为另外两个三角形。这两个三角形的三边可以轻松求出,然后利用海伦公式。我们还要考虑圆心角是钝角的情况,但是后来发现也符合这个公式。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;# 阅读全文
posted @ 2011-07-19 21:03 undefined2024 阅读(242) 评论(0) 推荐(0)
摘要: 用为操作把串压缩为longlong。然后排序。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 20005int n, m;long long f[maxn];int id[300];int ans[maxn];void input(){ getchar(); for (int i = 0; i < n; i++ 阅读全文
posted @ 2011-07-19 16:52 undefined2024 阅读(187) 评论(0) 推荐(0)
摘要: 二分简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 50005#define eps 10e-9struct Cistern{ double b, w, h, d;}cistern[maxn];double total;int n;double v;double maxh;int dblcmp(double a, double b){ if (a + eps & 阅读全文
posted @ 2011-07-19 16:10 undefined2024 阅读(206) 评论(0) 推荐(0)
上一页 1 ··· 103 104 105 106 107 108 109 110 111 ··· 182 下一页