In the clocktower of Prime City, the Royal Timekeeper maintains a giant modular clock. The clock has n positions, and every time the hand moves past position n-1, it wraps back to 0. The Timekeeper needs help computing sums under this modular system. "When you add two numbers on a modular clock, you add them normally, then take the remainder modulo n," the Timekeeper explains. "This is modular addition ÔÇö the foundation of all modular arithmetic." Given three integers a, b, and n, compute (a + b) mod n. The result must be in the range [0, n-1]. Constraints: 0 <= a, b <= 10^18, 1 <= n <= 10^9 Input: 5 3 7 Output: 1 Input: 10 20 6 Output: 0
Constraints:
0 <= a, b <= 10^18, 1 <= n <= 10^9
Tags:
