No.3454 Zodiac
タグ : / 解いたユーザー数 114
作問者 :
くらげ
hikikomori
Problem Statement
The Kingdom of MMA uses $2$ calendar cycles, called the $P$ stems and the $Q$ branches.
The $P$ stems cycle as $p = 1,\ 2,\ \dots,\ P,\ 1,\ 2,\ \dots$. The $Q$ branches cycle as $q = 1,\ 2,\ \dots,\ Q,\ 1,\ 2,\ \dots$.
That is, $p$ increases by $1$ each $1$ year, and when its value is $P$, it returns to $1$ upon reaching the next year.
Similarly, $q$ increases by $1$ each $1$ year, and when its value exceeds $Q$, it returns to $1$.
Now, it is known that in the year $Y_0$ of the era, the value of the $P$ stems is $p_0$ and the value of the $Q$ branches is $q_0$.
Find the $P$ stem and the $Q$ branch of the year $Y$ of the era.
Constraints
- $1 \le P,\ Q\le 1000$
- $1 \le Y_0,\ Y \le 2 \times 10^4$
- $1 \le p_0 \le P$
- $1 \le q_0 \le Q$
- All inputs are integers
Input
$P$ $Q$ $Y_0$ $p_0$ $q_0$ $Y$
Output
$p$ $q$Let $p$ be the value of the $P$ stems and $q$ be the value of the $Q$ branches, and output them on $1$ line.
Sample
Sample 1
Input
10 12 2025 2 6 2026
Output
3 7
The ten heavenly stems ( $P=10$ ) and the twelve earthly branches ( $Q=12$ ) are given.
The year $2025$ of the era was Otsu ( $p_0=2$ ), Mi ( $q_0=6$ ).
The year $2026$ of the era is Hei ( $p=3$ ), Uma ( $q=7$ ).
Sample 2
Input
314 217 1 1 1 218
Output
218 1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。