Input File Name: C.DAT
Program Source File: C.PAS or C.C or C.CPP
Bob needs money, and since he knows you are here, he decided to gamble intelligently. The game is rather simple: each player gets a sequence of integers. The players must determine, by using their mega-pocket computers, which is the maximum product value which can be computed with non empty sub-sequences of consecutive numbers from the given sequence. The winner is the one which gets first the right result.
Can you help Bob with a program to compute quickly the wanted product, particularly when the sequence is quite long ?
The input file contains sequences of numbers. Each sequence starts on a new line and may continue on several subsequent lines. Each sequence ends with the number -999 (which is not part of the sequence).
The maximum sub-sequence product for each sequence must be written on the standard output, on a different line. A simple example is illustrated in the figure below.
It is known that the products of sub-sequences are numbers which can be represented as long integers.