#B3770. Find Next Integer Satisfying Remainder Condition
Find Next Integer Satisfying Remainder Condition
Find Next Integer Satisfying Remainder Condition
Given three integers \(n\), \(k\), and \(d\), find the smallest integer \(n'\) such that:
\[ n' > n \]
and
\[ n' \bmod k = d \]
where \(n'\) can be written as \(ak + d\) for some integer \(a\) and \(d \ge 0\). Your task is to compute the minimal \(n'\) that satisfies these conditions.
inputFormat
The input consists of a single line containing three integers \(n\), \(k\), and \(d\) separated by spaces.
outputFormat
Output a single integer, the minimal integer \(n'\) that satisfies the conditions.
sample
7 5 2
12