11 2012 档案

摘要:View Code1#include<cstdlib>2#include<iostream>3#include<cstdio>4#include<cmath>5#include<cstring>6#include<string>7//#include<map>8#include<algorithm>9#include<set>10#include<vector>11#defineLLlonglong12#defineinf0x7fffffff13#defineE1e-914# 阅读全文
posted @ 2012-11-25 11:21 baoff 阅读(122) 评论(0) 推荐(0)
摘要:【题意】:给出一棵树,每条边的长度为1,问树上有多少点对的距离恰好为k。【题解】:用树的分治可解,但是写起来比较麻烦。 设状态dp[i][j]表示以i为根的子树的节点到i的距离恰为j的个数。 然后利用乘法原理求出答案,再把儿子的信息传给父亲。1#include<cstdlib>2#include<iostream>3#include<cstdio>4#include<cmath>5#include<cstring>6#include<string>7#include<map>8#include<algor 阅读全文
posted @ 2012-11-20 21:42 baoff 阅读(292) 评论(0) 推荐(0)
摘要:给出一个长度为N的串S(N≤500000)。这个串只包含“a”“b”两种字母。找一个长度为L的串T也是右“a”“b”两种字母组成使得该串不是串S的 子串且长度L尽可能小。 问题分析 这是一道统计的题目。由于串只由两种字母组成因此相当于一个01串。如果我们求出S的所有子串然后标记起来再由小到大枚举T串直到T串不是S的子串那么就能得出解了。然而S的子串是十分多的所以我们有必要分析一下这道题的特征。 题目要我们使长度L尽可能小。而对于某一个L串S中最多包含N-L+1个长度为L的子串。而长度为L的串一共有2L个。若N-L+1<2L则必有某个长度为L的串T不是S的子串。而N 阅读全文
posted @ 2012-11-10 23:36 baoff 阅读(193) 评论(0) 推荐(0)
摘要:View Code #include<cstdlib>#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include <algorithm>#include<vector>#include<set>#include<queue>#define LL long long#define inf 0x7fffffff#define E 1e-9#define N 10009using namespace st 阅读全文
posted @ 2012-11-02 19:55 baoff 阅读(193) 评论(0) 推荐(0)