| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1146 人关注过本帖
标题:ALMOST NO ONE CAN DO RIGHT!?
只看楼主 加入收藏
三少爷
Rank: 1
等 级:新手上路
帖 子:192
专家分:0
注 册:2004-4-29
收藏
 问题点数:0 回复次数:5 
ALMOST NO ONE CAN DO RIGHT!?


Arbitrage

Background

The use of computers in the finance industry has been marked with controversy lately as programmed trading -- designed to take advantage of extremely small fluctuations in prices -- has been outlawed at many Wall Street firms. The ethics of computer programming is a fledgling field with many thorny issues.

The Problem

Arbitrage is the trading of one currency for another with the hopes of taking advantage of small differences in conversion rates among several currencies in order to achieve a profit. For example, if $1.00 in U.S. currency buys 0.7 British pounds currency, £1 in British currency buys 9.5 French francs, and 1 French franc buys 0.16 in U.S. dollars, then an arbitrage trader can start with $1.00 and earn dollars thus earning a profit of 6.4 percent.

You will write a program that determines whether a sequence of currency exchanges can yield a profit as described above.

To result in successful arbitrage, a sequence of exchanges must begin and end with the same currency, but any starting currency may be considered.

The Input

The input file consists of one or more conversion tables. You must solve the arbitrage problem for each of the tables in the input file.

Each table is preceded by an integer n on a line by itself giving the dimensions of the table. The maximum dimension is 20; the minimum dimension is 2.

The table then follows in row major order but with the diagonal elements of the table missing (these are assumed to have value 1.0). Thus the first row of the table represents the conversion rates between country 1 and n-1 other countries, i.e., the amount of currency of country i ( ) that can be purchased with one unit of the currency of country 1.

Thus each table consists of n+1 lines in the input file: 1 line containing n and n lines representing the conversion table.

The Output

For each table in the input file you must determine whether a sequence of exchanges exists that results in a profit of more than 1 percent (0.01). If a sequence exists you must print the sequence of exchanges that results in a profit. If there is more than one sequence that results in a profit of more than 1 percent you must print a sequence of minimal length, i.e., one of the sequences that uses the fewest exchanges of currencies to yield a profit.

Because the IRS (United States Internal Revenue Service) notices lengthy transaction sequences, all profiting sequences must consist of n or fewer transactions where n is the dimension of the table giving conversion rates. The sequence 1 2 1 represents two conversions.

If a profiting sequence exists you must print the sequence of exchanges that results in a profit. The sequence is printed as a sequence of integers with the integer i representing the line of the conversion table (country i). The first integer in the sequence is the country from which the profiting sequence starts. This integer also ends the sequence.

If no profiting sequence of n or fewer transactions exists, then the line

no arbitrage sequence exists
should be printed.

Sample Input

3
1.2 .89
.88 5.1
1.1 0.15
4
3.1    0.0023    0.35
0.21   0.00353   8.13 
200    180.559   10.339
2.11   0.089     0.06111
2
2.0
0.45

Sample Output

1 2 1
1 2 4 1
no arbitrage sequence exists

[此贴子已经被作者于2005-1-7 11:16:02编辑过]

搜索更多相关主题的帖子: ALMOST CAN RIGHT ONE 
2005-01-07 11:08
kaikai
Rank: 1
等 级:新手上路
帖 子:236
专家分:0
注 册:2005-1-7
收藏
得分:0 
I found the problem statement at pku: http://acm.pku.edu.cn/JudgeOnline/showproblem?problem_id=1238 also uva 104.

Have you visit acm.tongji. lately?
2005-01-07 18:42
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
马甲,你不要拿这个ACM题出来混,我知道答案在哪里!
2005-01-07 20:20
kaikai
Rank: 1
等 级:新手上路
帖 子:236
专家分:0
注 册:2005-1-7
收藏
得分:0 
@live41
我不是马甲,这是俺真身:)
pku那连接上的[讨论]里面也有一个答案。

Have you visit acm.tongji. lately?
2005-01-08 02:36
poppylx
Rank: 1
等 级:新手上路
帖 子:367
专家分:0
注 册:2004-9-27
收藏
得分:0 
  ACM是什么  PKU又是什么  题目又是什么

动于心而静如水
2005-01-12 11:38
rountye
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2004-12-24
收藏
得分:0 
在网上看看就知道了

天自潇洒随己意,人又何故负今生!
2005-01-12 12:38
快速回复:ALMOST NO ONE CAN DO RIGHT!?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020362 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved