摘要: 思路:黑书的例题#include#include#include#include#define Maxn 1010using namespace std;int dp[Maxn][Maxn],v[Maxn][Maxn];char str[Maxn];void Out(int s,int e){ if(s>e) return ; if(s==e) { if(str[s-1]=='('||str[s-1]==')') printf("()"); else printf("[]"); ... 阅读全文
posted @ 2013-08-20 16:28 fangguo 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 思路:就是个比较裸的LCA了,不过要注意的是,如果a和b的公共祖先是a,那么答案就是farther[a]。#include#include#include#include#include#include#include#include#define Maxn 300010using namespace std;int vi[Maxn],pre[Maxn];int dep[Maxn],sec[Maxn],farther[Maxn];int e,Md;char str[Maxn][70],ans[Maxn][70];vector head[Maxn];map g;void init(){ M... 阅读全文
posted @ 2013-08-20 13:55 fangguo 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 思路:分等号左边和右边进行搜索#include#include#include#include#include#define LL __int64using namespace std;char str[20];int n,ans;void right(LL sum,LL now,int cnt){ if(cnt==n) { if(sum==now) ans++; return ; } if(sum==0) return ; if(sum>=now*10+(LL)(str[cnt]-'0')) ... 阅读全文
posted @ 2013-08-20 13:53 fangguo 阅读(154) 评论(0) 推荐(0) 编辑