AtCoder Beginner Contest 161
翻译中…
Problem Statement
翻译中…
Given any integer $x$, Aoki can do the operation below.
翻译中…
Operation: Replace $x$ with the absolute difference of $x$ and $K$.
翻译中…
You are given the initial value of an integer $N$. Find the minimum possible value taken by $N$ after Aoki does the operation zero or more times.
翻译中…
Constraints
翻译中…
$0 ≤ N ≤ 10^{18}$$1 ≤ K ≤ 10^{18}$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N K
翻译中…
Output
翻译中…
Print the minimum possible value taken by $N$ after Aoki does the operation zero or more times.
翻译中…
样例
Input #1
7 4
Output #1
1
Initially, $N=7$.
After one operation, $N$ becomes $|7-4| = 3$.
After two operations, $N$ becomes $|3-4| = 1$, which is the minimum value taken by $N$.
Input #2
2 6
Output #2
2
$N=2$ after zero operations is the minimum.
Input #3
1000000000000000000 1
Output #3
0
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。