程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> Problem C: Celebrity Split

Problem C: Celebrity Split

編輯:C++入門知識

Problem C: Celebrity Split


ÌâÄ¿ÃèÊö

Problem C: Celebrity Split

\Jack and Jill have decided to separate and divide their property equally. Each of their N mansions has a value between 1,000,000 and 40,000,000 dollars. Jack will receive some of the mansions; Jill will receive some of the mansions; the remaining mansions will be sold, and the proceeds split equally.

Neither Jack nor Jill can tolerate the other receiving prZ†·Ÿ"http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcGVydHkgd2l0aCBoaWdoZXIgdG90YWwgdmFsdWUuIFRoZSBzdW0gb2YgdGhlIHZhbHVlcyBvZiB0aGUgbWFuc2lvbnMgSmFjayByZWNlaXZlcyBtdXN0IGJlIGVxdWFsIHRvIHRoZSBzdW0gb2YgdGhlIHZhbHVlcyBvZiB0aGUgbWFuc2lvbnMgSmlsbCByZWNlaXZlcy4gU28gbG9uZyBhcyB0aGUgdmFsdWUgdGhhdCBlYWNoIHJlY2VpdmVzIGlzIGVxdWFsLAogSmFjayBhbmQgSmlsbCB3b3VsZCBsaWtlIGVhY2ggdG8gcmVjZWl2ZSBwcm9wZXJ0eSBvZiB0aGUgaGlnaGVzdCBwb3NzaWJsZSB2YWx1ZS48L3A+CjxwPgpHaXZlbiB0aGUgdmFsdWVzIG9mIDxzdHJvbmc+Tjwvc3Ryb25nPiBtYW5zaW9ucywgY29tcHV0ZSB0aGUgdmFsdWUgb2YgdGhlIG1hbnNpb25zIHRoYXQgbXVzdCBiZSBzb2xkIHNvIHRoYXQgdGhlIHJlc3QgbWF5IGJlIGRpdmlkZWQgc28gYXMgdG8gc2F0aXNmeSBKYWNrIGFuZCBKaWxsLjwvc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yby4gVGhpcyBsaW5lIGlzIG5vdCBhIHRlc3QgY2FzZSBhbmQgc2hvdWxkIG5vdCBiZSBwcm9jZXNzZWQuPC9wPgoKPGgyPgrK5LP20qrH8zwvaDI+Cgo8cD4KRm9yIGVhY2ggdGVzdCBjYXNlLCBvdXRwdXQgYSBsaW5lIGNvbnRhaW5pbmcgYSBzaW5nbGUgaW50ZWdlciwgdGhlIHZhbHVlIG9mIHRoZSBtYW5zaW9ucyB0aGF0IG11c3QgYmUgc29sZCBzbyB0aGF0IHRoZSByZXN0IG1heSBiZSBkaXZpZGVkIHNvIGFzIHRvIHNhdGlzZnkgSmFjayBhbmQgSmlsbC48L3A+CjxoMz4KPC9oMz4KCjxoMj4KvNnI58rkyOs8L2gyPgo8cHJlIGNsYXNzPQ=="brush:java;">5 6000000 30000000 3000000 11000000 3000000 0

Ó¦µ±Êä³ö

41000000

#include
#include
#include 
#include
#include
#include
using namespace std;
int sum[200],a[200],ans;
void fun();
void divide(int p,int diff,int hav)//p:Ê£Óà·¿×ÓÊý£¬differ:Á½È˲î¼Û£¬hav:Á½È˹²È¡×ßµÄÇ®
{
	int i,j,n;
	if(diff==0&&anssum[p])//¼ôÖ¦1
		return;
	if(sum[p]+hav>n&&n)
	{
		for(i=0;i>a[i];
			if(i==0)
				sum[i]=a[0];
			else
				sum[i]=sum[i-1]+a[i];
		}
		ans=0;
		divide(n-1,0,0);
		cout<





  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved