Mod Arithmetic
Time limit1sMemory limit256 MB
Given A, B and C, print (A+B)%C, ((A%C)+(B%C))%C, (AxB)%C and ((A%C)x(B%C))%C on four lines.
- Level
Easy1 of 10
- Topics
- Math
- Solved
- No attempts yet
Problem
You are given three numbers , , . Write a program that computes the following four values in order.
(A + B) % C((A % C) + (B % C)) % C(A × B) % C((A % C) × (B % C)) % C
Here % is the remainder operator, so x % y is the remainder of divided by .
Input
The first line contains , , in that order, separated by spaces. ()
Output
Print the four values on four lines, one per line. Print (A + B) % C on the first line, ((A % C) + (B % C)) % C on the second line, (A × B) % C on the third line, and ((A % C) × (B % C)) % C on the fourth line.