Logo
(追記) (追記ここまで)

21304번 - Marbles 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB124604244.211%

문제

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. You are to find the number of red marbles (r) and green (g) marbles so that rg, N ≤ (r+g) ≤ M ≤ 1000, 2 ≤ N ≤ 1000 and (r+g) is the smallest sum ≥ N. In addition, the probability of drawing one red marble and 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 1

예제 입력 2

2 3 4 10

예제 출력 2

2 2

예제 입력 3

2 5 10 15

예제 출력 3

NO SOLUTION

힌트

출처

ICPC > Regionals > North America > Greater New York Region > 2020 Greater New York Programming Contest E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /