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
編號 | 身分 | 題目 | 主題 | 人氣 | 發表日期 |
沒有發現任何「解題報告」 |