码迷,mamicode.com
首页 >  
搜索关键字:max sum plus plus    ( 46271个结果
Codeforces 279B Books
#include using namespace std; int a[100020]; int main() { int n,t; scanf("%d%d",&n,&t); int sum=0,k=1,Max=0; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); sum+=a[i];...
分类:其他好文   时间:2014-07-27 11:45:43    阅读次数:244
数位DP模板
解释一下:dp数组只保存!limit和!first的状态 dp数组保存的是,当前位确定后,之后的数字没有限制的结果,显然当limit或者first时候是不适合的。 first的时候是没必要记录的,因为到当前状态只有一条路径(当前位前边全零) limit的时候也是没必要记录的,因为到当前状态只有一条路径(当前位前边和待求得串相同) const int MAX_DIGITS, MAX_STAT...
分类:其他好文   时间:2014-07-27 11:37:25    阅读次数:322
poj Yogurt factory (贪心水题)
# include # include # include using namespace std; int main() { int i,n,s; __int64 sum ; int cost[10010],num[10010]; while(~scanf("%d%d",&n,&s)) { for(i=0;i<n;i++) scanf("%d%d",&cost[i],&...
分类:其他好文   时间:2014-07-27 11:34:02    阅读次数:144
HDU 2845 Beans
本来是很简单的一道题,却想了好长时间由于数据量比较大,所以逐行读入,逐行处理先处理每一行的不相邻元素和的最大值,记录在数组b中最后计算不相邻行的和的最大值二者的状态转移方程都类似:dp[j] = max(dp[j - 1], dp[j - 2] + a[j]); 1 //#define LOCAL ...
分类:其他好文   时间:2014-07-27 11:06:02    阅读次数:221
折半查找
首先,这个算法的确很简单,但是写了很多次还是自己不能完全的写对.上码分析: 1 #include 2 #include 3 #include 4 5 #define LENGTH 4 // 数组的长度 6 #define MAX 10 // 随机数的最大值 7 8 /...
分类:其他好文   时间:2014-07-27 10:18:52    阅读次数:151
POJ3274 hash
POJ3274问题重述:已知有n头牛,用一个K位二进制数Ak,Ak-1,...,A1表示一头牛具有的特征,Ai=1表示具有特征i。现给定按顺序排列的N头牛的k位特征值,称某个连续范围内“特征平衡”,假如在这个范围内,拥有各个特征的牛的数量都相等。求最大“特征平衡”连续范围。分析:用sum[i][j]...
分类:其他好文   时间:2014-07-26 17:00:01    阅读次数:354
[Leetcode]Combination Sum II
Leetcode Combination Sum II,略有疑惑求讨论...
分类:其他好文   时间:2014-07-26 15:30:12    阅读次数:155
Leetcode--Combination Sum II
Problem Description: Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only b...
分类:其他好文   时间:2014-07-26 15:24:02    阅读次数:252
hdu 4858 项目管理(vector模拟)
# include # include # include # include # define N 100005 using namespace std; vectorg[N]; int node[N]; int slove(int x) { int sum=0,i; for(i=0;i<g[x].size();i++) { sum+=node[g[x][i]]; } re...
分类:其他好文   时间:2014-07-26 15:21:40    阅读次数:224
POJ 1125 Stockbroker Grapevine (Floyd算法)
Floyd算法计算每对顶点之间的最短路径的问题 题目中隐含了一个条件是一个人可以同时将谣言传递给多个人 题目最终的要求是时间最短,那么就要遍历一遍求出每个点作为源点时,最长的最短路径长是多少,再求这些值当中最小的是多少,就是题目所求 #include using namespace std; int n,x,p,t; int m[120][120],dist[120][120],Max[12...
分类:其他好文   时间:2014-07-26 15:21:20    阅读次数:214
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!