Marbles
题号:NC226649
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

For a booth at the campus spring carnival, Toni wants to have players draw two marbles from a bowl of red and green marbles. Players go on to the next level of the game if one marble is red and one is green.

Toni wants to be able to choose the exact probability of drawing one red and one green marble. She wants enough marbles in the bowl to make it hard to guess the probability, but she needs to be able to limit the maximum number of marbles since her bowl is only so big.

Write a program to find out how many red and how many green marbles to put in the bowl.

输入描述:

Input consists of a single line containing four space separated decimal integers: p, q, N and M. Youare to find the number of red marbles (r) and green (g) marbles so that r ≤ g, N ≤ (r+g) ≤ M <= 1000, 2 ≤ N ≤ 1000 and (r+g) is the smallest sum ≥ N. In addition, the probability of drawing one red marbleand one green marble (not necessarily in that order) when drawing exactly two marbles at random from the bowl is exactly p/q. q > 0, GCD(p, q) will always be 1. If no solution exists that meet Toni’s requirements, then print out NO SOLUTION.

输出描述:

The single output line consists of two space separated decimal integers r followed by g or the words NO SOLUTION if no solution exists for the supplied input.
示例1

输入

复制
1 1 2 10

输出

复制
1 1
示例2

输入

复制
2 3 4 10

输出

复制
2 2
示例3

输入

复制
2 5 10 15

输出

复制
NO SOLUTION