Currency Exchange_poj1860

Description

Severalcurrency exchange points are working in our city. Let us suppose that eachpoint specializes in two particular currencies and performs exchange operationsonly with these currencies. There can be several points specializing in thesame pair of currencies. Each point has its own exchange rates, exchange rateof A to B is the quantity of B you get for 1A. Also each exchange point has some commission, thesum you have to pay for your exchange operation. Commission is always collectedin source currency.

For example,if you want to exchange 100 US Dollars into Russian Rubles at the exchangepoint, where the exchange rate is 29.75, and the commission is 0.39 you willget (100 - 0.39) * 29.75 = 2963.3975RUR.

Yousurely know that there are N different currencies you can deal with in ourcity. Let us assign unique integer number from 1 to N to each currency. Theneach exchange point can be described with 6 numbers: integer A and B - numbersof currencies it exchanges, and real RAB, CAB, RBA and CBA - exchange rates andcommissions when exchanging A to B and B to A respectively.

Nick hassome money in currency S and wonders if he can somehow, after some exchangeoperations, increase his capital. Of course, he wants to have his money incurrency S in the end. Help him to answer this difficult question. Nick mustalways have non-negative sum of money while making his operations.

 

Input

The firstline of the input contains four numbers: N - the number of currencies, M - thenumber of exchange points, S - the number of currency Nick has and V - thequantity of currency units he has. The following M lines contain 6 numbers each- the description of the corresponding exchange point - in specified aboveorder. Numbers are separated by one or more spaces. 1<=S<=N<=100,1<=M<=100, V is real number, 0<=V<=103.

For eachpoint exchange rates and commissions are real, given with at most two digitsafter the decimal point, 10-2<=rate<=102, 0<=commission<=102.

Let uscall some sequence of the exchange operations simple if no exchange point isused more than once in this sequence. You may assume that ratio of the numericvalues of the sums at the end and at the beginning of any simple sequence ofthe exchange operations will be less than 104.

Output

If Nickcan increase his wealth, output YES, in other case output NO to the outputfile.

Sample Input

3 2 120.0

1 2 1.001.00 1.00 1.00

2 3 1.101.00 1.10 1.00

Sample Output

YES

思路:

一眼识破这是典型的bell-man ford。题目要求我们求出是否存在一个环保证投入的钱可以经过兑换变多。注意要交税(雾

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值