摘要: 搜索,注意0是NOView Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int fac[20];bool f[1000005];int tot;void dfs(int i, int sum){ if (sum > 1000000) return; f[sum] = true; if (i == tot) return; dfs(i + 1, sum + fac[i]); dfs(i + 1, 阅读全文
posted @ 2011-06-14 20:51 undefined2024 阅读(159) 评论(0) 推荐(0)
摘要: 动态规划,可以把序列计算的所有过程中的得到的结果都%k,这样就可以大大缩小了空间与时间。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;bool f[2][205];int main(){ //freopen("t.txt", "r", stdin); int n, k; scanf("%d%d", &n, &k); 阅读全文
posted @ 2011-06-14 20:13 undefined2024 阅读(164) 评论(0) 推荐(0)
摘要: 题意:给出一段只有音高(整数表示),没有节奏的乐谱,问其中最长的曲调相同的没有重叠的两段的长度是多少。分析:后缀数组,一定要注意,吉大的模板的nlogn算法,要初始化n=strlen(s) +1,另外,s,sa,rank一定要从0位置开始使用。height从1位置开始有意义。这题是要在求出相邻音高之差之后找不重叠(无公共部分)的最长的重复出现过至少两次的串,也就是在height数组中找到一个连续段,其各项均大于d且sa数组中的对应段中最大值最小值之差要大于d。找到最大的d即可。d符合一个性质,就是小的d都满足,大的d都不满足。用二分法找分界线即可。View Code #include #inc 阅读全文
posted @ 2011-06-14 19:48 undefined2024 阅读(1137) 评论(0) 推荐(0)