INDIPROG - Indicator of progression

no tags 

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.

Input

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.

Output

For each test case output a single line with exactly 20 characters representing the mentioned display.

Example

Input:
2 5
2 6
0 10
-1 -1

Output:
********-40%--------
*******--33%--------
---------0%---------

hide comments
Martijn Muijsers: 2013-10-18 14:45:43

Great problem! To solvers: I recommend using math.h round method instead of cmath round, if you have that option.

Manu Narsaria: 2013-09-21 10:40:05

What should be the outputs for 50-60%??

Santiago Palacio: 2011-04-24 16:11:52

Could anyone give me a nasty test case? i0've tried like 30 times.
Is it really sure that M ≤ N ??

BTW alejandro, the 100% do work, you put 8 char at left, and 8 a t right, and 100% in the middle.

Last edit: 2011-04-26 01:28:26
Alejandro Hitti: 2011-04-10 14:05:43

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:

********50%--------
********55%--------
********59%*-------

Am I correct?

Also, "The indicator must be drawn as a string of exactly 20 characters."

That does not work out with 100%, where the string is 21 characters long.

Last edit: 2011-04-12 17:07:37
:D: 2010-12-06 07:28:09

re: shuaib akram
***------13%--------
********100%********

re: Pablo Ariel Heiber
The description is clear. I think it was referred to random line breaks.

shuaib akram: 2010-12-06 04:27:13

can any one tell me output for
1 8
10 10
-1 -1

thank you..

hendrik: 2010-10-01 15:22:20

The problem statement is sufficient to solve it.

[Rampage] Blue.Mary: 2010-09-01 00:26:05

He means that the presentation of the problem statement need some improvement.

Pablo Ariel Heiber: 2010-09-01 00:26:05

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

Micha³ Ma³afiejski: 2010-09-01 00:26:05

please, improve the problem statement (editorial)


Added by:Pablo Ariel Heiber
Date:2010-08-13
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 VB.NET
Resource:FCEyN UBA ICPC Selection 2007