上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 57 下一页

2017年1月3日

ZOJ 1442 Dinner Is Ready 容斥原理 + java大数

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=442 求解 x1 + x2 + x3 + .... + xn = m 其中xi属于[L, R] 不同解的个数。 这题需要用大数,要注意。 原理和以前做的一样。容斥。先算出每个xi大 阅读全文

posted @ 2017-01-03 23:01 stupid_one 阅读(157) 评论(0) 推荐(0) 编辑

2017年1月2日

A. Writing Code 完全背包

摘要: http://codeforces.com/contest/543/problem/A 一开始这题用了多重背包做,结果有后效性。 就是如果6,这样拆分成 1 + 2 + 3的,那么能产生3的就有两种情况了(同一种物品,两种情况,所以有了后效性) 分别是1 + 2 = 3和0 + 3 = 3 以前的多 阅读全文

posted @ 2017-01-02 17:08 stupid_one 阅读(146) 评论(0) 推荐(0) 编辑

2017年1月1日

C. Shaass and Lights 组合数学

摘要: http://codeforces.com/contest/294/problem/C 把那个数组n分段了,那么有两类。 1、开头和端点那些,就是只有一端在开始的,这个时候,要开完这些灯,只能循序渐进,1--2--3--4 2、第二类就是中间那些,两端都可以开始,那些段的开灯次数是2^(len - 阅读全文

posted @ 2017-01-01 00:09 stupid_one 阅读(167) 评论(0) 推荐(0) 编辑

2016年12月31日

一题超级字符串,

摘要: 我现在是不会的了。 看看等我退役前能不能做出吧。 https://www.hackerrank.com/contests/w27/challenges/how-many-substrings 阅读全文

posted @ 2016-12-31 13:13 stupid_one 阅读(166) 评论(0) 推荐(0) 编辑

B. Checkout Assistant 01背包变形

摘要: http://codeforces.com/problemset/problem/19/B 对于每个物品,能偷多ti个,那么先让ti + 1, 表示选了这个东西后,其实就是选了ti + 1个了。那么只需要选出>=n个即可。 一开始的时候想不到ti + 1,一直不知道能多选ti个后,本来是选了多少个。 阅读全文

posted @ 2016-12-31 12:45 stupid_one 阅读(279) 评论(0) 推荐(0) 编辑

2016年12月30日

背包九讲 && 题目

摘要: ★、背包求方案数的时候,多重背包是不行的,因为产生重复的背包会有多种情况。 ★、背包记录路径的时候,其实是不行的,因为更新了12的最优解,如果它依赖于6这个背包,然后你后面改变了6这个背包,就GG 1、01背包问题。 tot:总背包空间,vall[i]:每件物品的价值,w[i]:每件物品的重量 ht 阅读全文

posted @ 2016-12-30 22:31 stupid_one 阅读(2092) 评论(0) 推荐(0) 编辑

B. Shaass and Bookshelf DP

摘要: http://codeforces.com/contest/294/problem/B 据说是贪心,我用了一个复杂度是2e8的dp水过去了。 其实这题就是给你n个数,每个数有两个权值,分成两组,使得第一个权值之和,和第二个权值之和的最大值最小。 那么直接设dp[i][j][k][h]表示前i个数中, 阅读全文

posted @ 2016-12-30 22:30 stupid_one 阅读(219) 评论(0) 推荐(0) 编辑

C. Dima and Salad 背包好题

摘要: http://codeforces.com/contest/366/problem/C 在n个物品中选出若干个,使得sum(a[i]) = k * sum(b[i]) 把问题转化一下就是,求sum(a[i] - k * b[i]) = 0的最大的a[i],这个时候已经把a[i]作为价值了 那么怎么去 阅读全文

posted @ 2016-12-30 16:49 stupid_one 阅读(286) 评论(0) 推荐(0) 编辑

2016年12月28日

getch 和 getchar 在 windows 和 unix下的区别

摘要: 注意getch()是从console读取,(非标准函数) getch()需要的头文件是<conio.h>。 而getchar()是从stdin,一般是指键盘 windows平台下ENTER键会产生两个转义字符 \r\n, \r : 回到开头的地方。 \n : 去到下一行开头 因此,getch()读到 阅读全文

posted @ 2016-12-28 00:12 stupid_one 阅读(347) 评论(0) 推荐(0) 编辑

2016年12月27日

J. Bottles 二维费用背包问题

摘要: http://codeforces.com/contest/730/problem/J 3 4 36 1 90 45 40 其实可以知道,选出多少个瓶子呢?是确定的,当然选一些大的。 那么问题转化为: 在n个瓶子中,选出k个,然后把剩余的n - k个瓶子得液体转移过去这k个里面,费用最小。其实就是使 阅读全文

posted @ 2016-12-27 16:34 stupid_one 阅读(211) 评论(0) 推荐(0) 编辑

上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 57 下一页

导航