• [E] Exchange Rate

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • You know, every country's currency has an exchange rate to another country.
    For example, 'Dollir' : 'RNB' is 1 : 6.
    And exchanging from one currency to another currency, it will have a wastage.
    Now give some currency and their each wastage from one currency exchanges to another. For every currency, you should tell me when it exchanges to other currency and finally exchanges to itself, the minimum wastage it will cost.

  • 输入
  • This problem contains several cases.
    The first line of each case is an integer N (2 <= N <= 100).
    Then follows a decimal matrix(N * N). The Cell(i, j) indicates the wastage exchanging from ith currency to jth currency. (1.00 < Cell(i, j) <= 100.00).
    You may consider that every currency can't exchange to itself directly, so every Cell(i, i) will be -1.
  • 输出
  • For each case, you may output N lines.
    Each line is an decimal, indicates exchanging from ith currency and finally it exchanges to itself, the minimum wastage it will cost.
    Two decimal places.
  • 样例输入
  • 4
    -1 1.00 2.00 10.00
    1.00 -1 2.00 30.00
    1.00 1.00 -1 50.00
    50.00 50.00 1.0 -1
    
  • 样例输出
  • 2.00
    2.00
    3.00
    12.00
    
  • 提示
  • 来源
  • XadillaX
  • 操作

显示春菜