上一页 1 ··· 110 111 112 113 114 115 116 117 118 ··· 182 下一页
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 105int f[maxn];int main(){ //freopen("t.txt", "r", stdin); int n; scanf("%d", &n); for (int i = 0; 阅读全文
posted @ 2011-07-10 15:47 undefined2024 阅读(133) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;char st[2][15] ={ " /\\ ", "/__\\" };int n;char cal(int x, int y, int r){ if (r == 2) return st[y][x]; if (x < r / 2 && y < r / 2) return 阅读全文
posted @ 2011-07-10 15:32 undefined2024 阅读(288) 评论(0) 推荐(0)
摘要: 题意:一些士兵站在矩阵的一些方格内,现要把他们移动到一横排,并连续地排成一队,问最少需要移动多少步。分析:先将他们移动到同一横排,这横排应该是他们纵坐标的中位数,才能使得此过程总步数最少。然后要把他们紧凑起来。我们先把横坐标排序,并假设起点是a,那么我们就是要求i=1~n,abs(a+i - xi)的加和。即i=1~n,abs(a-(xi - i))的加和。我们构建一个新数列zi = xi - i,当a 等于z的中位数时原式的值最小。综上我们可以得到一个普遍结论,就是对于一个数列Xi(i=1~n),取一个X使得i=1~n时abs(Xi-A)的加和最小,那么A应该是数列Xi的中位数。Xi不一定是 阅读全文
posted @ 2011-07-10 14:58 undefined2024 阅读(1060) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 50005struct Interval{ int a, b;}interval[maxn];int n;bool operator < (const Interval &a, const Interval &b){ if (a.a == b 阅读全文
posted @ 2011-07-10 14:18 undefined2024 阅读(248) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 10005bool quest[1000006];int n, ans;int main(){ //freopen("t.txt", "r", stdin); scanf("%d", &n); memset(quest, 0, sizeof(que 阅读全文
posted @ 2011-07-10 13:58 undefined2024 阅读(126) 评论(0) 推荐(0)
上一页 1 ··· 110 111 112 113 114 115 116 117 118 ··· 182 下一页