Time Limit: 1000 ms
Memory Limit: 32768 ms
Huangwei_njust is having an adventure now. Fortunately, he finds a cave that no one has discovered before. He is sure that there must be some jewellery in the cave. So he happily went in. The cave is full of all kinds of traps and mazes and so on. But as you know, Huang is very brilliant and he has learnt all kinds of algorithms engaged with network flow, graphs, and search skills. So, this can’t trap him. But now he is stopped by a thick door. He can’t open it using any methods. He has found that there are a sequence of numbers on the door, and two blanks to fill in. He doesn’t know what to do.
Then God appears. “This is the last barrier for you and I will tell you what this problem means,” the god said. “You should use these numbers to make a largest number and a smallest one. You have two operations. The first is, you pick any three numbers from the sequence, multiply them, and add the number 1 to the result, and the result will replace the three numbers you choose. The second is, you pick any two numbers, and do as I said as before. When the sequence has only one number, this is the final result. You should find the biggest and the smallest result you could ever make. ” However, Huang is not as excellent at math as he is at other fields. He needs your help. If he succeeds to get the jewellery, he will give some to you as a reward.