欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

hdu 1712 ACboy needs your help 分組背包

系統(tǒng) 1833 0

轉(zhuǎn)載請注明出處: http://blog.csdn.net/u012860063

題目鏈接: http://acm.hdu.edu.cn/showproblem.php?pid=1712

Problem Description
ACboy has N courses this term, and he plans to spend at most M days on study.Of course,the profit he will gain from different course depending on the days he spend on it.How to arrange the M days for the N courses to maximize the profit?
?
Input
The input consists of multiple data sets. A data set starts with a line containing two positive integers N and M, N is the number of courses, M is the days ACboy has.
Next follow a matrix A[i][j], (1<=i<=N<=100,1<=j<=M<=100).A[i][j] indicates if ACboy spend j days on ith course he will get profit of value A[i][j].
N = 0 and M = 0 ends the input.
?
Output
For each data set, your program should output a line which contains the number of the max profit ACboy will gain.
?
Sample Input
        
2 2 1 2 1 3 2 2 2 1 2 1 2 3 3 2 1 3 2 1 0 0
?
Sample Output
        
3 4 6

題意:一開始輸入n和m,n代表有n門課,m代表你有m天,
然后給你一個數(shù)組,val[i][j],代表第i門課,在通過j天去修,
會得到的分?jǐn)?shù)。求在m天能得到的最大分?jǐn)?shù)。

      #include <cstdio>
#include <cstring>
#define N 147
int max(int a, int b)
{
	if(a > b)
		return a;
	return b;
}
int main()
{
	int n,m,a[N][N],dp[N];
	int i, j, k;
	while(~scanf("%d%d",&n,&m)&&( n || m))
	{
		memset(dp,0,sizeof(dp));
		for(i = 1; i <=n ; i++)
		{
			for(j = 1; j <= m ;j++)
			scanf("%d",&a[i][j]);
		}
		for(i = 1 ; i <= n ; i++)//第一重循環(huán):分組數(shù)
		{
			for(j = m ; j >= 1 ; j--) //第二重循環(huán):容量體積
			{
				for(k = 1 ; k <= j ; k++) //第三重循環(huán):屬于i組的k
				{
					dp[j]=max(dp[j],dp[j-k]+a[i][k]);
				}
			}
		}
		printf("%d\n",dp[m]);
	}
	return 0;
}
    


hdu 1712 ACboy needs your help 分組背包


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 欧美日韩专区国产精品 | 亚洲精品中文字幕乱码一区二区 | 中文字幕在线一区二区三区 | 精品国产九九 | 亚洲欧美综合乱码精品成人网 | 国产精品人妻无码八区仙踪林 | 亚洲日本中文字幕永久 | 又爽又黄又无遮挡的激情视频免费 | 亚洲国产日韩欧美在线 | 亚洲精品一二三区-久久 | 色qing网站| 日韩欧美在线观看视频一区二区 | 在线视频综合视频免费观看 | 国产美女自卫慰视频福利 | 日韩影视在线 | 日本一本久道 | 免费的污污网站 | 久久久久无码国产精品一区 | 久久精品亚洲精品国产欧美kt∨ | 久久99精品亚洲热综合 | 久久精品国产免费看久久精品 | 欧美手机在线观看 | 色亚洲色图 | 国产亚洲女人久久久久久 | 欧美亚洲国产一区 | 欧美精品在线一区二区三区 | 一级特黄欧美日韩免费视频 | 日韩不卡一区二区 | 精品欧美一区二区三区久久久 | 久久精品久 | 日韩一区二区不卡 | 日韩在线免费看网站 | 99久久精品日本一区二区免费 | 欧美色无极| 黑人性xxxⅹxxbbbbb | 天天做天天添天天谢 | 日韩不卡高清 | 成人免费观看在线网址 | 欧美成人午夜 | 欧美日韩一区在线观看 | 日韩成人在线播放 |