a082: Stock trading 股票買賣
標籤 : Comprehensive
通過比率 : 75% (3 人 / 4 人 ) (非即時)
評分方式 :
Tolerant

最近更新 : 2020-04-16 08:49

內容

Xiaoming is a professional stock analyst. He can use the data to analyze the rise and fall of stocks. The data is the closing price of a certain stock in a week. Please help him design a simple gadget that can choose the days to buy and sell stocks. It can make Xiaoming the most profitable. Assume that you can only choose to buy or sell stocks once a day, only one buy and sell in a week.

 

小明是專業的股票分析師,能夠利用數據分析約一周內股票的漲跌,數據為一周內某支股票的收盤價。請你幫他設計出一個簡單的小工具,能夠選出一周內最佳的買股日及賣股日,以使小明的獲利最多。假設一天只能選擇買或賣,且一周內只能買賣各一次。

輸入說明

The input consists of seven real numbers (stock prices of a week) separated by spaces.

 

輸入為為一周內每一天的股價,中間以空白區隔。

輸出說明

If there is a profit, the output contains three lines.

The first line is the best buy date, the second line is the best sell date, and the third line is Profit. Take two digits below the decimal point.

 

If there is no profit, just only output "No profit!".

 

若有獲利,則輸出共三行結果,第一行為最佳買股日(Best buy date),第二行為最佳賣股日(Best sell date),第三行為獲利(Profit),小數點以下取兩位。

若無法獲利,只需輸出 "No profit!"。

範例輸入
55.39 109.23 48.29 81.59 81.58 105.53 94.45
範例輸出
Best buy date:3
Best sell date:6
Profit:57.24
測資資訊 :
記憶體限制 : 64 MB
隱藏 測資點#0 (50%): 3.0s , <1K
隱藏 測資點#1 (50%): 3.0s , <1K
提示 :
標籤:
Comprehensive
出處:
ITSA 教育部智慧創新跨域人才培育計畫 [編輯 :
zero_jason (zero_jason(MANAGER))
]


編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」