程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> substring-Cutting Necklace

substring-Cutting Necklace

編輯:編程解疑
Cutting Necklace

Description

Today is Valentine's Day. Gnaf Ynot is going to present a beautiful necklace to his girl friend Mxxjx. He has bought a necklace of pearls some time ago. The necklace consists of many sheeny pearls and is very pretty. However, the necklace is too long for his girl friend. So Gnaf Ynot has to cut a slice from the necklace so that he can get a shorter one. He wants that the cut slice of necklace can be as evenly bright as possible, i.e. the average brightness of the slice should be maximized. Gnaf Ynot requests your help.

The necklace is in the form of a ring of pearls. Each pearl has a brightness. Your task is to cut a substring of pearls from the ring, so that the substring has the largest average brightness of pearls. The substring you cut should not be too long or too short as well. To help Gnaf Ynot making Mxxjx happy, please try your best to solve this problem!
Input

Input contains multiple test cases. Each test case starts a line containing three numbers N, L, U (1 <= L <= U <= N <= 1000000), which are the number of pearls of the necklace, the permitted shortest length and the longest length of the cut slice. Then the following line gives the brightness of each pearl (the value of brightness are integers and in the range of [-1000, 1000]).
Output

For each test case print the largest average brightness of the slice you cut from the necklace in one line. The result should be represented using fraction form such as A/B (here A and B are integers, B > 0 and (A, B) = 1).
Sample Input

4 2 3
4 -1 3 1
4 2 2
4 -1 3 1
Sample Output

8/3
5/2

最佳回答:


http://www.xuebuyuan.com/1295249.html

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved