摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("t.txt", "r", stdin); int t; scanf("%d", &t); while (t--) { int year, month, day, hour, minute, second; scanf(" 阅读全文
posted @ 2011-07-10 18:00 undefined2024 阅读(179) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 100int n, w, s;char name[maxn][100];bool out[maxn];int main(){ //freopen("t.txt", "r", stdin); scanf("%d", &n); for (int i = 阅读全文
posted @ 2011-07-10 16:23 undefined2024 阅读(276) 评论(0) 推荐(0)
摘要: 简单题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)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>using namespace std;int main(){ //freopen("t.txt", "r", stdin); int t; scanf("%d", &t); while (t--) { int a; scanf("%d", & 阅读全文
posted @ 2011-07-10 13:31 undefined2024 阅读(175) 评论(0) 推荐(0)
摘要: 用java,高精度。读入高精度数可以直接用cin.nextBigInteger();但本题要使用BigDecimal。因为本题读入的整数前端有+号View Code import java.io.*;import java.util.*;import java.math.*;public class Main { public static void main(String args[]) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); int t; t = cin.nextInt(); for (int i = 阅读全文
posted @ 2011-07-10 13:19 undefined2024 阅读(234) 评论(0) 推荐(0)
摘要: 题意:给出一些木棍,必须全都用上,问能拼成的最大的三角形面积是多少。分析:动态规划,f[i][j][k]表示用前i根木棍能否构成两条长度分别为j,k的边。f[i][j][k] = f[i - 1][j][k];if (j >= fence[i]) f[i][j][k] = f[i][j][k] || f[i - 1][j - fence[i]][k];if (k >= fence[i]) f[i][j][k] = f[i][j][k] || f[i - 1][j][k - fence[i]];以上过程只是构成两条边,第三条边的长度可以用总长度减去前两条边得到。 之前没有考虑这三条边 阅读全文
posted @ 2011-07-10 10:49 undefined2024 阅读(191) 评论(0) 推荐(0)