编程介的小学生 2016-12-15 10:16 采纳率: 20.5%
浏览 861
已采纳

Similarity of necklaces 2

Description

The background knowledge of this problem comes from "Similarity of necklaces". Do not worry. I will bring you all the information you need.

The little cat thinks about the problem he met again, and turns that problem into a fair new one, by putting N * (N + 1) / 2 elements into a linear list, with M = N * (N + 1) / 2 elements:

(The above table denotes Table and Pairs in description of after converting)

One more array named "Multi" appears here. Suppose Pairs and Multi are given, the little cat's purpose is to determine an array Table with M integers that obey:

(this condition is similar with the condition

that appears in the problem "Similarity of necklaces") and make

as large as possible. What is more, we must have Low[i] <= Table[i] <= Up[i] for any 1 <= i <= M. Here Low and Up are two more arrays with M integers given to you.
Input

The input contains a number of test cases. Each of the following blocks denotes a single test case. A test case starts by an integer M (1 <= M <= 200) and M lines followed. The i-th line followed contains four integers: Pairs[i], Multi[i], Low[i], Up[i].

Restrictions: -25 <= Low[i] < Up[i] <= 25, 0 <= Pairs[i] <= 100000, 1 <= Multi[i] <= 20. From the input given, you may assume that there is always a solution.
Output

For each test case, output a single line with a single number, which is the largest

Sample Input

10
7 1 1 10
0 2 -10 10
2 2 -10 10
0 2 -10 10
0 1 1 10
0 2 -10 10
0 2 -10 10
0 1 1 10
0 2 -10 10
0 1 1 10

10
0 1 1 10
2 2 -10 10
2 2 -10 10
2 2 -10 10
0 1 1 10
2 2 -10 10
2 2 -10 10
0 1 1 10
2 2 -10 10
0 1 1 10
Sample Output

90
-4

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-12-15 15:53
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图