CT111

Fair Remainder for the Caravan

EasyL1 · Pixel PusherAcceptance: 0.0%XP: 5

The caravan ledger needs a remainder that stays nonnegative even for a negative balance. Task: Find r such that a=qb+r for an integer q and 0<=r<b. Input format: Integers a and positive b. Output format: Print the unique nonnegative remainder r. Constraints: -10^12 <= a <= 10^12; 1 <= b <= 10^9

Example 1:

Input: -7 3
Output: 2

Example 2:

Input: 7 3
Output: 1

Example 3:

Input: 9 3
Output: 0

Constraints:

-10^12 <= a <= 10^12; 1 <= b <= 10^9

Tags:

modulo integers
Loading...
Test Cases:No test cases
No test cases available.
Fair Remainder for the Caravan - EASY Coding Problem | CodeTikki