P1083 借教室

摘要: 思路:前缀和, c表示对于当前的middle, 前缀和 include using namespace std; const int maxn = 1e6+1; int n, m, now, r[maxn], d[maxn], s[maxn], t[maxn], c[maxn]; bool chec 阅读全文
posted @ 2016-11-11 10:46 蒟蒻konjac 阅读(122) 评论(0) 推荐(0) 编辑

P1236 算24点

摘要: ``` include using namespace std; int b[4]; int a[3]; int calc(int a, int b, int c) { if(c == 1) return a + b; else if(c == 2) return a b; else if(c == 阅读全文
posted @ 2016-11-09 20:07 蒟蒻konjac 阅读(526) 评论(0) 推荐(2) 编辑

P2296 寻找道路

摘要: ``` include using namespace std; const int maxn = 10005; set to[maxn]; queue q;int s, t;int n, m;set to2[maxn]; int dist[maxn], used[maxn], dist2[maxn 阅读全文
posted @ 2016-11-08 21:28 蒟蒻konjac 阅读(168) 评论(0) 推荐(0) 编辑

P1351 联合权值

摘要: ``` include using namespace std; const int maxn = 200005; vector son[maxn]; int v[maxn], s[maxn], w[maxn]; int main() { freopen("input.in", "r", stdin 阅读全文
posted @ 2016-11-07 21:38 蒟蒻konjac 阅读(132) 评论(0) 推荐(0) 编辑

P1541 乌龟棋

摘要: 30分做法,暴力枚举: include using namespace std; const int maxn = 400; int n, m; int a[maxn], b[maxn]; //a:格子,b:卡牌 void read() { cin n m; for(int i = 0; i a[i 阅读全文
posted @ 2016-11-07 20:42 蒟蒻konjac 阅读(153) 评论(0) 推荐(0) 编辑

P1018 乘积最大

摘要: 开始定义状态f[i][j][k]为[i,j)区间插入k个括号,使用记忆化搜索,但是成功爆栈,得到4个mle include using namespace std; const int maxn = 45; int n, k, len; long long f[maxn][maxn][maxn]; 阅读全文
posted @ 2016-11-07 19:53 蒟蒻konjac 阅读(142) 评论(0) 推荐(0) 编辑

模板-高精度BigInteger

摘要: ``` #include using namespace std; struct BigInteger { static const int BASE = 100000000; static const int WIDTH = 8; vector s; BigInteger(long long num = 0) { *this = num; } // 构造函数 BigInte... 阅读全文
posted @ 2016-11-07 11:54 蒟蒻konjac 阅读(177) 评论(0) 推荐(1) 编辑

P2882 Face The Right Way - USACO07MAR

摘要: 这道题没有一个比较详细的题解,我来提供一份。 首先我们可以知道,反转区间的顺序对结果没有影响,而且一个区间如果翻转两次以上是没有意义的,所以,问题就变成了求哪些区间需要反转。 我们枚举k。对于每一个k,我们设计一个calc函数来判断k的操作次数。 显然的,我们可以设计出一种方法,就是每一次都检查最左 阅读全文
posted @ 2016-11-07 10:51 蒟蒻konjac 阅读(262) 评论(0) 推荐(0) 编辑

P1970 花匠

摘要: 状态定义是dp中非常重要的,可以直接影响到效率,如此题,第一种思路是: include using namespace std; const int maxn = 100005; struct node { int high, value; bool operator value pf, pg; f 阅读全文
posted @ 2016-11-06 21:44 蒟蒻konjac 阅读(145) 评论(0) 推荐(0) 编辑

P1149 火柴棒等式

摘要: ``` include using namespace std; const int num[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}; int dp[2000]; int solve(int k) { if(dp[k]) return dp[k]; if(k n; n 阅读全文
posted @ 2016-11-03 19:38 蒟蒻konjac 阅读(169) 评论(0) 推荐(0) 编辑