上一页 1 2 3 4 5 6 ··· 11 下一页

2013年11月23日

摘要: 这个题目 正解应该是 dp 吧 对18个数字进行2进制枚举放不放,,,可以这么理解 以当前状态 stu,他对应的余数是 h 进入下一个状态; 进行记忆画搜索就行了 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 char str[20]; bool vis[20]; 9 int dp[1000000][20],len; int res[20];10 int dfs( int stu,int h,int dep )11 {12 if( dep == len ){... 阅读全文
posted @ 2013-11-23 21:32 浪舟 阅读(310) 评论(0) 推荐(0) 编辑
摘要: 这个题 还是比较简单的; 把案例 想出来是怎么来的;差不多就出来了; 只要从前往后扫,遇到一个子序列就统计一次,更新起点; 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 char str[112345],cha[112]; 9 int main( )10 {11 while( scanf("%s%s",str+1,cha+1) != EOF )12 {13 int len1 = strlen(str+1); int len2 = st... 阅读全文
posted @ 2013-11-23 20:08 浪舟 阅读(361) 评论(0) 推荐(0) 编辑
摘要: 这个题目 其实可以暴力 用两个 set 合并; 每次放进去一个元素只要找到这个元素第一个比他大的元素和最后一个比他小的元素;然后更新最优值;证明为什么不会超时; 假如最后集合的小的为 S1,大的集合为S2; 这样将 S1合并到S2; 这样S2 》= S1×2;合并 t 次后 大小就成了 S1×(2^t); 但是集合大小只有N 个元素 也就是说 N 》= S1×(2^t ); 但S1等于1时 也就是说一个元素最多合并t 《= log(N) 次; 1 #include 2 #include 3 #include 4 #include 5 #include 6 #inc 阅读全文
posted @ 2013-11-23 19:14 浪舟 阅读(498) 评论(0) 推荐(0) 编辑
摘要: 题解 现将字符串排序; 那么某前缀在字符串中出现肯定是连续的;写几个案例就知道了;这是记录每个字符在以前缀排名的rank ; 然后将字符串反序; 再排序;依照前缀,可以知道相同名字的后缀也会出现在一段排序好的连续的字符串里面;这样得到前缀的区间为 [a,b], [c,d]; 只要统计每个字符是否在 a 到 b 之间; 同时满足在 c 到 d 之间; 获取某个前缀的第一个匹配段字符串 和 最后一个字符串也就是 [a,b] 使用了字典树搞; 然后 再用线段树保留最大值和最小值;竟然没有超时, 啊,,哈哈;#include#include#include#include#include#... 阅读全文
posted @ 2013-11-23 13:03 浪舟 阅读(436) 评论(0) 推荐(0) 编辑

2013年11月19日

摘要: 先分组,然后暴力;注意 初始化时不要为0 会有负数;我直接二进制枚举; dfs是正解;呵呵#include #include #include #include #include #include #include #include using namespace std;int arr[25][25];mapmp;char str[1000],cha[1000];struct date{ int val,i; bool operator v[6];vectors[6];char sss[5][55] = {"0","goalkeeper"," 阅读全文
posted @ 2013-11-19 21:50 浪舟 阅读(219) 评论(0) 推荐(0) 编辑

2013年11月18日

摘要: 题目链接 http://poj.org/problem?id=3517题意 约瑟夫环 要求最后删掉的那个人是谁;方法 理解递推公式就行了 考虑这样一组数据 k = 3 是 长度为 N 的约瑟夫环 k,k+1,k+2,k+3,k+4,k+5,k-2, k-1 长度为N-1的约瑟夫环 0, 1, 2, 3, 4, 5, n-2, n-1 则 f[n] = (f[n-1]+k)%N;可以将第一步 预处理出来; 然后 套公式就行了;#include#include#include#includeusing namespace std;int arr[100... 阅读全文
posted @ 2013-11-18 10:31 浪舟 阅读(179) 评论(0) 推荐(0) 编辑

2013年11月13日

摘要: 题解 白书上 总和一定的 dp 题;经典题 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int dp[105][105],M,sum[105],arr[105]; 8 int main( ) 9 {10 while( scanf("%d",&M) && M )11 {12 memset( dp,0,sizeof(dp) );13 memset( sum,0,sizeof(sum) );14 for( int i = 1; i <=... 阅读全文
posted @ 2013-11-13 18:51 浪舟 阅读(175) 评论(0) 推荐(0) 编辑

2013年10月10日

摘要: 看代码就懂了 不解释 3 1 1 1 1 2 2 2 1 1 1 3 第一个3 和最后一个 3 只需要一个就够了,,, 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int dp[5005],num[5005],arr[5005]; 9 int main( )10 {11 int N; scanf("%d",&N);12 for( int i = 1; i = 1; j-- )20 if( arr[i] dp[i] )23 ... 阅读全文
posted @ 2013-10-10 20:34 浪舟 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 方法 LCS 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 short int dp[5002][5002]; char str[5123]; 9 int main( )10 {11 int N;12 while( scanf("%d",&N) != EOF )13 {14 scanf("%s",str+1); int len = strlen( str+1 );15 memset( dp,0,sizeof(dp) );... 阅读全文
posted @ 2013-10-10 17:02 浪舟 阅读(162) 评论(0) 推荐(0) 编辑

2013年10月9日

摘要: 看了 dp 方程之后应该是妙懂每次 加入一个数,×2 然后剪掉重复的; 重复的个数 维前面那个数,,,,, 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define mod 1000000007 7 using namespace std; 8 9 long long dp[1123456],pre[1123456];10 int main( )11 {12 int N;13 while( scanf("%d",&N) != EOF )14 {15 memset( pre,0,si.. 阅读全文
posted @ 2013-10-09 21:30 浪舟 阅读(297) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 11 下一页

导航