INDIPROG - Indicator of progression
When dealing with a long task, computers often provide a progress indicator to help users
estimate how much longer they will have to wait. This is especially useful when copying a large
number of data files from one drive to another.
In the Institute of Computer Power Control (ICPC) are very concerned about their brand new
file copier, which they think will change forever the way people copy files. While this is a great
accomplishment for the engineers in ICPC, the lack of a progress indicator is threatening the
future of the project and the well being of most computer users around the world!
The Supremum Principal Director Manager of ICPC has called you personally to ensure you
are up for the task. The interface provided by the developing team of the file copier only gives
two integers M and N . M is the number of files that have already been copied, and N is
the total number of files to be copied. Using this information, you must write a module that
displays the progress indicator.
The indicator must be drawn as a string of exactly 20 characters. The first K of them must
be asterisks (“*”) and the rest must be hyphens (“-”). The number K must be chosen in such
a way that K/20 correctly approximates M/N ; this means that the distance between the two
mentioned fractions is minimum. If there is more than one possible value for K, the greatest
one must be chosen.
Also, for more precision, a number P without leading zeroes and followed by a percentage
sign (“%”) must be written on top of the described indicator. Since the goal is to represent
the finished percentage, the number P must be such that P/100 correctly approximates M/N ,
with the same policy as before. The finished percentage must be centered on top of the display.
This means that if possible, the same number of display characters (“*” or “-”) must be seen
to the left and to the right of the percentage; if this is not possible, exactly one extra character
must be seen to the left.
The input contains several test cases. Each test case is described in a single line that contains
two integers M and N as explained above (0 ≤ M ≤ N ≤ 109 and N ≠ 0). These values are
separated by a single space. The last line of the input contains the number −1 twice separated
by a single space and should not be processed as a test case.
For each test case output a single line with exactly 20 characters representing the mentioned
Great problem! To solvers: I recommend using math.h round method instead of cmath round, if you have that option.
What should be the outputs for 50-60%??
Could anyone give me a nasty test case? i0've tried like 30 times.
I have a question... what would be the input for 50-55%? Because the numbers would be exactly above the progress bar, so any number in that range would output the same result, like so:
re: shuaib akram
can any one tell me output for
The problem statement is sufficient to solve it.
He means that the presentation of the problem statement need some improvement.
Pablo Ariel Heiber:
can you clarify what do you think needs improvement? we used it as it is in the actual contest and I think 10/10 teams solved it without any clarification
please, improve the problem statement (editorial)