No.3557 KCPC or KUPC 2
タグ : / 解いたユーザー数 63
作問者 :
jastaway
yaaya
butsurizuki
Problem Statement
Now that you have become a university student, you have decided to start a part-time job.
There are two candidate employers: KCPC Inc. and KUPC Inc.
At KCPC Inc., the initial daily wage is $A$ yen, and it rises by $C$ yen for every $B$ days worked.
At KUPC Inc., the initial daily wage is $D$ yen, and it rises by $F$ yen for every $E$ days worked.
Here, "the initial daily wage is $x$ yen, and it rises by $z$ yen for every $y$ days worked" strictly means the following.
- Counting the first day of work as day $1$, the daily wage on day $i$ is $\displaystyle x+z \times \left \lfloor \frac{i-1}{y} \right \rfloor$ yen. ( $\lfloor x \rfloor$ denotes $x$ rounded down to an integer by discarding its fractional part.)
You will choose one of the companies and work there every day from now on.
At which company can you earn $N$ yen sooner?
Print KCPC if it is KCPC Inc., KUPC if it is KUPC Inc., and Same if both take the same number of days.
Input
The input is given from standard input in the following format.
$N$ $A$ $B$ $C$ $D$ $E$ $F$
- $1\leq N\leq 10^{16}$
- $1\leq A, B, C, D, E, F\leq 10^6$
- All input values are integers.
Partial Score
This problem has partial scoring based on subtasks.
| Subtask | Score | Constraints |
|---|---|---|
| 部分点1 | 10% (20 pts) | $N \le 10^6$ |
| 部分点2 | 40% (80 pts) | $N \le 10^9$ |
| 部分点3 | 50% (100 pts) | 追加の制約はない |
Output
Print KCPC if the answer is KCPC Inc., KUPC if the answer is KUPC Inc., and Same if both take the same number of days.
Sample
Sample 1
Input
10000 1200 2 100 1500 3 50
Output
KUPC
The daily wages at KCPC Inc., starting from day $1$, are $1200,1200,1300,1300,1400,1400,1500,1500,\dots$ yen, and the total reaches at least $10000$ yen on day $8$.
The daily wages at KUPC Inc., starting from day $1$, are $1500,1500,1500,1550,1550,1550,1600,1600,\dots$ yen, and the total reaches at least $10000$ yen on day $7$.
You can earn $10000$ yen sooner at KUPC Inc.
Sample 2
Input
10000000000000000 1000000 1 1000000 1000000 1 1000000
Output
Same
Sample 3
Input
1000000000 3 1 4 1 5 9
Output
KCPC
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。