eolymp
bolt
Try our new interface for solving problems
Problems

The Lost Gift

The Lost Gift

Stan is in deep shock as he has lost some part of the precious gift given by Olie. The precious gift was actually two boxes full of crystal balls. The crystal balls of one box were all red and that of the other box were all black. While handing over the gift Olie told him with a wicked smile, "\textit{Stan! If you mix the balls of the two boxes well and randomly pick two balls from the mixture, the probability of them being the same color is }\textit{\textbf{½}}". Stan was returning home merrily with the two boxes, but suddenly the box containing black balls fell from his hand and the black balls scattered all around the place. Stan looked all around the place and was able to collect at least \textbf{70}\% of the black balls. Given the total number of red balls and the number of black balls found your job is to find out the number of lost black balls. \InputFile Each line contains two positive integers \textbf{r} and \textbf{b}. Here \textbf{r} is the total number of red balls and \textbf{b} is the number of black balls found by Stan. Input is terminated by a line containing two zeroes, which should not be processed. \OutputFile For each line of input produce one line of output. If the number of red balls \textbf{R} is invalid according to the above story then print "\textbf{No. of red balls invalid}". If the number of red balls is valid but the number of black balls found seems invalid then print the line "\textbf{No. of black balls invalid}" instead. If the total number of red balls and black balls found seems valid then print in a single line one or more integers. All these integers denote the possible number of lost black balls. These numbers should be separated by a single space and sorted in ascending order.
Time limit 1 second
Memory limit 64 MiB
Input example #1
10 5
11 1
0 0
Output example #1
1
No. of red balls invalid