自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 【DP】 HDOJ 2974 Counting heaps

推出dp公式然后就可以做了。。#include #include #include #include #include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 500005;queue q;int fa[maxn];int in[

2015-10-30 13:55:51 540

原创 【DP】 cf 487B

用队列转移dp即可。。。#include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 100005;int P[maxn];int a[maxn];int dp[maxn];int st1[maxn][20];int st2[maxn][

2015-10-29 19:51:40 560

原创 【DP】 cf 486D

考虑每个点作为最小的权值点。。。然后dp#include using namespace std;typedef long long LL;const int mod = 1000000007;const int maxn = 2005;const int maxm = 4005;struct Edge{ int v; Edge *next;}E[maxm], *H[m

2015-10-29 16:48:02 514

原创 【DP】 cf 590D Top Secret Task

#include using namespace std;typedef long long LL;const int maxn = 155;const int INF = 0x3f3f3f3f;int dp[maxn][maxn * maxn];void update(int &x, int y){ if(x > y) x = y;}void work(){ int

2015-10-28 14:25:33 1074

原创 Codeforces Round #325 (Div. 2) D. Phillip and Trains

水题,bfs一下即可。。。#includeusing namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 105;queue >q;int vis[5][maxn];char g[5][maxn];int n, m;bool check(int x, in

2015-10-13 17:47:24 426

原创 Codeforces Round #325 (Div. 2) E. Alice, Bob, Oranges and Apples

模拟一下发现和gcd一样。。。于是按gcd模拟就好了。。。#includeusing namespace std;typedef long long LL;void work(){ LL a, b; scanf("%I64d%I64d", &a, &b); if(__gcd(a, b) != 1) { printf("Impossible\n"); return; }

2015-10-13 14:59:49 636

原创 Gym 100726B Common Subexpression Elimination

递归下降建树,然后对每个节点编号....一个节点该节点的hash值和左儿子的编号和右儿子的编号是唯一的....用map查询#include using namespace std;typedef long long LL;const int maxn = 800000;struct node{ int val, id, is; string s; node *ch[2];

2015-10-09 16:54:44 652

原创 线段树 FZU 2201 序列操作

把gcd转化成差值...然后建立两颗线段树....#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;typedef long lon

2015-10-09 15:41:07 641

原创 矩阵快速幂 CodeForces - 582B Once Again...

建出转移矩阵...然后做矩阵快速幂就行了....#include using namespace std;typedef long long LL;const int maxn = 105;const int INF = 0x3f3f3f3f;int mat[maxn][maxn];int res[maxn][maxn];int mid[maxn][maxn];int a[

2015-10-05 20:34:15 1305

原创 HDOJ 5498 Tree

容斥一下然后生成树计数就行了....#include using namespace std;typedef long long LL;const int maxn = 105;int a[maxn][maxn];LL c[maxn][maxn];int base, n, m, q;int det(int n){ int ans = 1, i, j, k;

2015-10-04 20:06:40 419

原创 线段树 CodeForces 580E

线段树上的hash...#include using namespace std;typedef long long LL;#define lson o << 1, L, mid#define rson o << 1 | 1, mid+1, R#define ls o << 1#define rs o << 1 | 1const int mod = 1e9+7;const i

2015-10-03 18:29:06 629

原创 mobius HDOJ 5468 Puzzled Elena

dfs遍历树+莫比乌斯反演..#include using namespace std;typedef long long LL;const int maxn = 100005;const int maxm = 200005;struct Edge{ int v; Edge *next;}E[maxm], *H[maxn], *edges;int not_prime[

2015-10-02 19:37:12 477

原创 树链剖分 JAG Summer 2012 Day 4 D Do use segment tree

树链剖分裸题....#include using namespace std;typedef long long LL;#define lson o << 1, L, mid#define rson o << 1 | 1, mid+1, R#define ls o << 1#define rs o << 1 | 1const int INF = 0x3f3f3f3f * 2;

2015-10-02 18:40:43 407

原创 DP HDOJ 5471 Count the Grid

先转化成了离散网格图,然后状态dp即可....#include using namespace std;typedef long long LL;#define mp(x, y) make_pair(x, y)const int maxn = 100;const int mod = 1e9+7;struct line{ int x1, y1, x2, y2, v; lin

2015-10-01 20:01:21 479

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除