PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BF0000051. Kinh doanh chênh lệch tỷ giá (Arbitrage)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Kinh doanh chênh lệch tỷ giá (Arbitrage)
Arbitrage
Source: POJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given named currencies and directed exchange rates, decide whether any cyclic sequence of exchanges yields more than the initial amount of currency.
Input
Read currency names, then directed rates source rate target.
Output
Print Yes or No.
Subtasks
- Subtask 1 (20 points): , ; Each name has no spaces; all rates are positive real numbers.
- Subtask 2 (30 points): , ; Each name has no spaces; all rates are positive real numbers.
- Subtask 3 (50 points): , ; Each name has no spaces; all rates are positive real numbers.
Examples
Input
2
USD
EUR
2
USD 0.90 EUR
EUR 1.20 USD
Output
Yes
Explanation
One USD becomes EUR, then USD. Since the product , profitable arbitrage exists, giving Yes.