問題一覧 > 通常問題

No.3454 Zodiac

レベル : / AI推定難易度 : 140 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 114
作問者 : t5ugu / テスター : くらげ dyktr_06 おのせ hikikomori tyawanmusi
お気に入りにしたユーザー ProblemId : 13021 / 自分の提出
問題文最終更新日: 2026-02-27 23:44:26
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
MMA Contest 021 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。