Classic
Clean & simple
Crystal
Glassmorphism + Neon
Cyberpunk
Neon glitch art
🚫
违规Action检测
禁止Use右键菜单
⚠️ 此Action已被系统记录
1

Number Partitioning Problems

📝 Solutions 🔵 仅限 C++
Problems Description
<p><span style="font-family: ';font-size:10.5pt;'">Consider the partition problem: given a set S of n positive integers, partition it into two disjoint subsets S<sub>1</sub> and S<sub>2</sub> such that the discrepancy</span></p> <p><span style="font-family: ';font-size:10.5pt;'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;E(S) = |sum(S<sub>1</sub>) - sum(S<sub>2</sub>)|<br /> </span></p> <p><span style="font-family: ';font-size:10.5pt;'">is minimized, where sum(S<sub>i</sub>) is <span style="font-family: ';font-size:10.5pt;'">the sum of S<sub>i</sub>'s elements</span>. Design an exhaustive search algorithm for this problem.</span></p>
Input格式
<p>Input includes multiple groups of data. The first line of each group of data is an integer n (10 &lt;= n &lt;= 20). n = 0 means that the input is over. Each of the next n lines has an integer which belongs to a set to be partitioned.</p>
Output格式
<p>For each test data, output the minimum discrepancy of two subsets into which the test data is partitioned.</p>
Sample
Sample Input 1
10 205 157 133 111 100 91 88 59 47 23 8 635 853 401 868 335 435 704 754 0
Sample Output 1
0 3
Submit Code
请先Login后Submit

🤖 AI 解题助手

OpenRouter
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这problems题,可以帮你points析思路、提供Code示例。
🔓 完全Free · 无需消耗 Token