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+Tjwvc3Ryb25nPiBtYW5zaW9ucywgY29tcHV0ZSB0aGUgdmFsdWUgb2YgdGhlIG1hbnNpb25zIHRoYXQgbXVzdCBiZSBzb2xkIHNvIHRoYXQgdGhlIHJlc3QgbWF5IGJlIGRpdmlkZWQgc28gYXMgdG8gc2F0aXNmeSBKYWNrIGFuZCBKaWxsLjwvcD4KPHA+CjwvcD4KPGgzPgpFeGFtcGxlPC9oMz4KPHA+ClN1cHBvc2UgSmFjayBhbmQgSmlsbCBvd24gNSBtYW5zaW9ucyB2YWx1ZWQgYXQgNiwwMDAsMDAwLCAzMCwwMDAsMDAwLCAzLDAwMCwwMDAsIDExLDAwMCwwMDAsIGFuZCAzLDAwMCwwMDAgZG9sbGFycy4gVG8gc2F0aXNmeSB0aGVpciByZXF1aXJlbWVudHMsIEphY2sgb3IgSmlsbCB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mUgc29sZCBzbyB0aGF0IHRoZSByZXN0IG1heSBiZSBkaXZpZGVkIHNvIGFzIHRvIHNhdGlzZnkgSmFjayBhbmQgSmlsbC48L3A+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&&ans sum[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<