编程介的小学生 2017-05-11 15:08 采纳率: 20.5%
浏览 765
已采纳

Equivalence

When learning mathamatics, sometimes one may come to an theorem which goes like this:
The following statements are equivalent:

a)......
b)......
c)......

For example, let A be an angle between 0 and 360 degrees, the following statements are equivalent:

a)A = 90 degrees;
b)A is a right angle;
c)sin(A) = 1.

Proving such a theorem is usually a difficult task, because you have to prove that for any two statements Si and Sj, Si concludes Sj and vise versa. Sometimes, proving Si concludes Sj directly is quite difficult so we may find a Sk and prove that Si concludes Sk and Sk concludes Sj. Now given the difficulty of proving every Si => Sj, you are to calculate the minimal total difficulty to prove that the given statements are equivalent.

Input

The input contains several cases. Each case begins with an integer n (2 <= n <= 6), the number of statements in this case, followed by n lines, each contains n integers.

The jth integer of the ith row represents the difficulty of proving Si => Sj. The ith integer of the ith row is always 0 as it's obvious that Si concludes Si. All the n * n integers are between 0 and 100, inclusively. Input is terminated by EOF.

Output

For each test case, output a line with the minimal difficulty for that case.

Sample Input

4
0 2 3 4
5 0 7 8
9 10 0 12
13 14 15 0

Sample Output

34

  • 写回答

1条回答 默认 最新

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

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP