No.3179 3 time mod
レベル :
/ AI推定難易度 : 1125
/ 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 512 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 92
作問者 :
Cafe1942
/ テスター :
tsunamayo123
kk2a
sclara
タグ : / 解いたユーザー数 92
作問者 :
Cafe1942
/ テスター :
tsunamayo123
問題文最終更新日: 2025-06-13 19:47:00
English (AI translation)
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 470
(順位表)
の他の問題:
Problem Statement
How many non-negative integers not exceeding $N$ have remainder $A$ when divided by $P$, remainder $B$ when divided by $Q$, and remainder $C$ when divided by $R$?
Constraints
- $0 \leq N \leq 10^{18}$
- $1 \leq P,Q,R \leq 10^6$
- $P,Q$ are coprime
- $Q,R$ are coprime
- $R,P$ are coprime
- $0 \leq A < P$
- $0 \leq B < Q$
- $0 \leq C < R$
- All input values are integers
Input
$N$ $P$ $Q$ $R$ $A$ $B$ $C$
Output
Print a newline at the end.
Sample
Sample 1
Input
71 2 3 5 0 1 2
Output
2
The numbers satisfying the $3$ remainder conditions are $22$ $,$ $52$ $,$ $82$ $,...$. Among these, the ones that are at most $N ( = 71 )$ are the $2$ numbers $22$ $,$ $52$, so print $2$.
Sample 2
Input
2005 1 1 1 0 0 0
Output
2006
Note that $1$ and $1$ are coprime. Also note that $0$ may be a number satisfying the conditions.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。