No.1663 Maximum Remainder
問題文最終更新日: 2026-04-28 14:42:02
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 312
(順位表)
の他の問題:
Problem Statement
Find the maximum value of $(x+y)$ $\bmod$ $m$ over integers $x,$ $y$ satisfying $a\leq x\leq b$ and $c\leq y\leq d$.
Here, $A$ $\bmod$ $B$ denotes the remainder when $A$ is divided by $B$.
Input
$a$ $b$ $c$ $d$ $m$
- All input values are integers.
- $1\leq a\leq b\leq 1000$
- $1\leq c\leq d\leq 1000$
- $1\leq m\leq 1000$
Output
Print the answer on a single line.
Sample
Sample 1
Input
2 4 3 5 7
Output
6
For example, when $x=y=3$, $(x+y)$ $\bmod$ $m$ equals $6$, which is the maximum.
Sample 2
Input
1 1 5 6 9
Output
7
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
だれ
nok0