Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Easy Math

By Hasinur_ · Limits 2s, 512 MB

You will be given three integers a, b, m. Print ( ab ) mod m. There will be 30 test cases at most in an input file. In each case a and b both will be integer numbers of at most 105 digits.

Input

There will be multiple test cases in each input file . Each line of the input file will contain three integer numbers a , b and m (1 ≤ m ≤ 1.5*109).

a and b both will be integer numbers of at most 105 digits.
Input will be terminated when a = 0 , b = 0 and m = 0. This line should not be processed.
Each input file contains 30 test cases at most.

Output

For each case, print ( ab ) mod m in a new line.

Sample

InputOutput
7 2 11
4 2 3
19 1 5
0 0 0
5
1
4

Discussion

Statistics


23% Solution Ratio

IOI_StfuFfsEarliest, Mar '18

tahoangquan2Fastest, 0.1s

Tarik.amtolyLightest, 262 kB

anonyo.akandShortest, 78B

Submit

Login to submit

Related Contests

Toph uses cookies. By continuing you agree to our Cookie Policy.