上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 71 下一页
摘要: Problem Statement We have balls of K different colors. The colors are numbered 0 through K-1, and the number of balls of color i is X[i]. We want to divide the balls into as few packages as possible. Each package must contain between 1 and K balls, inclusive. Additionally, each package must be eithe 阅读全文
posted @ 2014-02-16 21:23 _雨 阅读(251) 评论(0) 推荐(0) 编辑
摘要: Problem Statement Vocaloids Gumi, Ia, and Mayu love singing. They decided to make an album composed of S songs. Each of the S songs must be sung by at least one of the three Vocaloids. It is allowed for some songs to be sung by any two, or even all three Vocaloids at the same time. The number of son 阅读全文
posted @ 2014-02-16 20:29 _雨 阅读(330) 评论(0) 推荐(0) 编辑
摘要: 链接发个长长的模拟 这题要注意的地方挺多 -的个数 以及对齐的情况 全都注意好了 大数的加减乘就可以了 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std; 10 #define N 510 11 char s1[N],s2[N]; 12 int s[N][N*2],o[N]; 13 int main() 14 { 15 int t,i,j,k1,k2,len; 16 char c,tc; 1... 阅读全文
posted @ 2014-02-15 21:06 _雨 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 一简单的状压题 比赛时跑偏了 ,脑子最近乱的跟浆糊似得呢。。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 int dp[15][5010],o[15][5010]; 9 int w[15][15],ee[15][15],s[15];10 int main()11 {12 int i,j,n,t,e;13 cin>>t;14 while(t--)15 {16 memset(dp,0,sizeof(dp));17... 阅读全文
posted @ 2014-02-15 16:58 _雨 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 链接next数组的巧妙应用 学弟出给学弟的学弟的题。。求最长的 是前缀也是后缀同时也是中缀的串 next的数组求的就是最长的前后缀 但是却不能求得中缀所以这里 就把尾部去掉之后再求 这样就可以保证是中缀了 先把所有既是前缀也是后缀的长度的求出来标记 然后再去掉尾部 求一下最大 既是前缀又是后缀的长度 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 #define INF 0xfffffff11 #define N 1. 阅读全文
posted @ 2014-02-15 16:14 _雨 阅读(741) 评论(3) 推荐(2) 编辑
摘要: 链接题目大意就相当于 跟你一串字符串 让你截成k段 使总体的值最小想法是递归的 递归太慢 可以转换为递推的这样就有可以推出状态方程 dp[i][j] = max(dp[i][j],dp[i-1][g]+sum[g+1][j]+sum[1][g]-sum[1][j]); dp[i][j]表示总长度为j第i次截的最小值 后面的sum[i][j]表示的就是从i开始作为第一个到j个的花费 o[i][j]保存路径 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #defi. 阅读全文
posted @ 2014-02-15 15:24 _雨 阅读(345) 评论(0) 推荐(0) 编辑
摘要: 1389算个简单的树形DP吧 不知道是不是数据太水 竟然一A了就是对于当前节点有没有被选中就行选最优 有没有被选中的意思是有没有与它相连的边被选中 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define N 10001010 vectord[N];11 int dp[N][3],g;12 struct node13 {14 int u,v;15 }p[N];16 int dfs(int u,int v,int f)17 {... 阅读全文
posted @ 2014-02-13 16:59 _雨 阅读(325) 评论(0) 推荐(0) 编辑
摘要: 1326用队列优化的 不知道为什么一直WA 传统直白的 状压 写了超时 O((1 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define N 110000010 #define INF 0xfffffff11 int dp[2][N];12 int p[25],o[110],sum[110];13 vectora[110];14 bool f[2][N],ff[25];15 int main()16 {17 int i,j,n,m,v,s=0;1... 阅读全文
posted @ 2014-02-11 17:21 _雨 阅读(472) 评论(0) 推荐(0) 编辑
摘要: 1238这算模拟加记忆化吗 找bug找了2个多小时。。记忆化部分好想 就是字符串处理部分挫了 一个个复制模拟 各种修改查找 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define INF 0xfffffff 9 int dp[110][110],o[110][110]; 10 char s[110][110][110],ss[110]; 11 int len(int x) 12 { 13 int q=0; 14 whi... 阅读全文
posted @ 2014-02-11 13:32 _雨 阅读(402) 评论(0) 推荐(0) 编辑
摘要: 1410dp水题 题意读了好一会 是不能连续读两个及以上单词 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 #define N 1001011 int dp[N],len[N];12 char s[N][30],ss[N*100];13 int main()14 {15 int i,g=0;16 while(scanf("%c",&ss[g])!=EOF)17 {18 g++... 阅读全文
posted @ 2014-02-10 20:03 _雨 阅读(176) 评论(0) 推荐(0) 编辑
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 71 下一页