問題一覧 > 通常問題

No.846 Medals

レベル : / AI推定難易度 : 425 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 274
作問者 : chocorusk / テスター : zunda1st
お気に入りにしたユーザー ProblemId : 2860 / 自分の提出
問題文最終更新日: 2019-07-05 21:10:44
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 217 (順位表) の他の問題:

Problem Statement

A mathematics contest was held in the country of yuki, and all participants received distinct ranks. In this contest, medals are awarded to some of the participants as follows.

  • Let $N$ be the total number of participants.
  • The top $\lceil N/P\rceil$ participants are awarded gold medals.
  • Among the top $\lceil N/Q\rceil$ participants, everyone who has not yet been awarded a medal is awarded a silver medal.
  • Among the top $\lceil N/R\rceil$ participants, everyone who has not yet been awarded a medal is awarded a bronze medal.

Here, for a real number $x$, $\lceil x\rceil$ denotes the smallest integer greater than or equal to $x$ (that is, the value of $x$ rounded up to an integer).

Rusk does not know the total number of participants $N$, but he heard in the news that the numbers of people awarded gold, silver, and bronze medals are $A$, $B$, and $C$, respectively.

Determine whether there exists a possible value of the total number of participants $N$, and if so, find the minimum and maximum values of $N$.

Input

$P\ Q\ R$
$A\ B\ C$

  • $2\leq R < Q < P \leq 10^9$
  • $0\leq A, B, C\leq 10^9$
  • $A > 0$
  • All input values are integers.

Output

If no possible value of the total number of participants $N$ exists, output $-1$ on its own. If one exists, output the minimum and maximum values in this order, separated by a space.

Sample

Sample 1
Input
12 4 2
9 16 25
Output
99 100

For example, if there are $100$ participants:

  • First, the top $\lceil 100/12\rceil =9$ participants are awarded gold medals.
  • Next, among the top $\lceil 100/4\rceil =25$ participants, the $16$ who have not been awarded a gold medal are awarded silver medals.
  • Next, among the top $\lceil 100/2\rceil =50$ participants, the $25$ who have not been awarded a gold or silver medal are awarded bronze medals.

Sample 2
Input
6 3 2
3 3 4
Output
-1

It is impossible for the numbers of gold, silver, and bronze medalists to be $3$, $3$, and $4$, respectively. The news is false.

Sample 3
Input
7 5 3
1 0 0
Output
1 3

Sample 4
Input
789123456 456789123 123456789
157 114 729
Output
123333332212 123456789000

Note that the answer may not fit in a $32$-bit integer type.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。