Internet Problem Solving Contest

IPSC 2005

Problem P – Polly Wanna Cracker

And not only Polly! Mirko has got many parrots (exactly P) and Polly is just one of them. (She made it to the problem statement title just because her name starts with P. 'Parrots want crackers' just doesn't sound good... it ain't got the right melody, you know...)

In recent days Mirko is trying hard to teach the parrots to repeat... like parrots. - Safko je na prd! - Safko je na prd, repeat the parrots; and they are rewarded. They get their crackers.

When distributing the crackers, Mirko tries to be as fair as possible. (The last thing he needs now is to offend one of the parrots.) Thus he used the most simple way he could think of:

At the beginning he arranges all parrots to form a circle. Then he gives a cracker to the first parrot, the second one, and all the way around to the P-th parrot. Then he continues again with the first one, the second one, ... until he runs out of crackers.

Task specification

Given the number of parrots P and the number of crackers N output a statistic of how many parrots got how many crackers.

Input specification

Input consists of several lines; each line contains one instance of the problem - the number of parrots P and the number of crackers N.

Output specification

For each line of the input give a statistic of the form

p1 n1
p2 n2
p3 n3


meaning p1 parrots ate n1 crackers each, p2 parrots ate n1 crackers each, and so on. The statistic should be sorted by the number of crackers in decreasing order. Do not output unnecessary lines (with pi=0). Different statistics should be separated by a blank line.


3 8
5 47
2 3
1 2

2 10
3 9

Problemsetter(s): AFAIK this was the result of some heavy brainstorming :)
Contest-related materials: Kubo, Palo