摘要: #include <cstdio>using namespace std;void print(char s, int size){ for (int i = 0; i < size-1; ++i) { for (int j = 1; j <= size+i; ++j) { if (j == size+i || j == size-i) { printf("%c", s); } else { printf(" "); } ... 阅读全文
posted @ 2012-04-19 20:57 沐阳 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 博客里面还有以前写的解题报告,表示没看懂。这里直接计算其没有被录取的概率,每次去小的值即可代码如下:#include <cstring>#include <cstdio>#include <cstdlib>#define MAXN 1005using namespace std;int N, M, s[MAXN];double p[MAXN], dp[10005];inline double min(double x, double y){ return x < y ? x : y;}void zobag(int x){ for (int i = N; 阅读全文
posted @ 2012-04-19 17:24 沐阳 阅读(285) 评论(0) 推荐(0) 编辑
摘要: #include <cstdlib>#include <cstring>#include <cstdio>#define MAXN 105using namespace std;int N, seq[MAXN][MAXN], dp[MAXN][MAXN];inline int max(int x, int y){ return x > y ? x : y;}int DP(){ for (int i = 1; i <= N; ++i) { dp[N][i] = seq[N][i]; } for (int i = N-1; i >= 1; -- 阅读全文
posted @ 2012-04-19 17:00 沐阳 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 通过给定的数据组成可及的状态。最后再中中间开始遍历所有可及的状态。就是一个完全背包,用二进制优化。代码如下:#include <cstdlib>#include <cstdio>#include <cstring>#define MAXN 250005using namespace std;int N, dp[MAXN], p[55], n[55], total;void zobag(int x) { for (int i = total>>1; i >= x; --i) { if (dp[i-x]) { dp[i] = 1; } ... 阅读全文
posted @ 2012-04-19 16:45 沐阳 阅读(268) 评论(0) 推荐(0) 编辑