如何把这一组数据分成 18个数组或集合 并且每一个组数据总和大于3200 。
数据如下
435,435,435,435,
425,425,425,425,425
410,410,410,410,410,410
405
390,390,390,390
345,345,345,345,345,345,345,345,345,345,345
330,,330,330,330,330,330,330,330
325,325,325,325,325,325,325
310,310,310,310,310,310,310,310,310,310,
310
305,305,305,305,305,305,305
295
290,290,290,290,290,290,290,290
275,275,275,275
270,270,270,270,270
255
245,245,245,245,245,245,245,245,245,245,
245,245,245,245,245,245,245,245,245,245,
245,245,245,245
230,230,230,230
225,225,225,225,225,225,225,225,225,225,
225,225,225,225,225,225,225
220
210
205,205,205,205,205,205,205,205,205,205,
205,205,205,205,205,205,205,205,205,205,
205,205,205,205,205,205,205,205,205,205,
205,205,205,205,205,205,205,205,205,205,
205,205,205,205,205,205,205,205,205,205,
205,205,205,205,205,205,205,205,205,205,
205,205
195,195,195,195,195,195,195,195,195,195,
195,195,195,195,195,195,195,195,195,195,
195,195,195
190
185,185,185
125,125,125,125,125,125,125,125,125
70
总共:229条数据
判断条件:
1. 把数组分为 18个数组
2. 每个数组都要包含一个 如上 加粗的数据(345,345,345,345,345,345, //6个
325,325,325,325,325,325,325 //7个
270,270,270,270,270 ) // 5个
// 总计18个
3. 每个数组总和加起来的和大于3200
.
.
不知用数组好 还是集合好。
个人思路如下:
int[] a1 = {345}; // 1.把数组分好
int[] a2 = {345};
int[] a3 = {345};
int[] a4 = {345};
int[] a5 = {345};
int[] a6 = {345};
int[] a7 = {325};
int[] a8 = {325};
int[] a9 = {325};
int[] a10 = {325};
int[] a11 = {325};
int[] a12 = {325};
int[] a13 = {325};
int[] a14 = {270};
int[] a15 = {270};
int[] a16 = {270};
int[] a17 = {270};
int[] a18 = {270};
// 2.把分组用的元素从 集合中拿掉
// 3. 就没思路了..... 求诸位大大指点
新人小白第一次发帖 , 请多关照 , 诸位大大多多指教。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论