Topcoder 463 Div 2 1000
Problem Statement |
|||||||||||||
Taro and Hanako are playing a game called Nisoku, which is played as follows. Initially, there is a pile of cards. Each card contains a real number between 1.5 and 10.0, inclusive. You are given a vector <double> cards, the i-th element of which is the number written on the i-th card. Repeat the following step until there is only one card left in the pile: Remove any two cards from the pile, and add one new card to the pile. Write either a+b or a*b on the new card, where a and b are the numbers written on the two cards that were removed. Return the maximal possible number written on the final card in the pile. |
|||||||||||||
Definition |
|||||||||||||
|
|||||||||||||
Notes |
|||||||||||||
- | Your return value must have an absolute or relative error less than 1e-9. | ||||||||||||
Constraints |
|||||||||||||
- | cards will contain between 2 and 50 elements, inclusive. | ||||||||||||
- | Each element of cards will be between 1.5 and 10.0, inclusive. | ||||||||||||
Examples |
|||||||||||||
0) | |||||||||||||
|
|||||||||||||
1) | |||||||||||||
|
|||||||||||||
2) | |||||||||||||
|
|||||||||||||
3) | |||||||||||||
|
|||||||||||||
4) | |||||||||||||
|
發(fā)現(xiàn)偶還是太水了。。。


































誰能證明下這份代碼的正確性?
posted on 2010-03-02 22:27 abilitytao 閱讀(1066) 評論(0) 編輯 收藏 引用