MNYC '16: King Modulus

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Atharva hates modulo (long story). Due to this hate, he learned everything possible about modulo and has been self-named King Modulus. He wants you to share his frustration of modulo by giving you a task. Given two integers N and M, find the value of NmodM. The answer for NmodM can be viewed as the remainder of a division, where N is the dividend and M is the divisor. The result of a modulo operation is always non-negative. Here is an example of how the modulo operation works:

NmodM=(NM)modM=(N2M)modM==(N+M)modM=(N+2M)modM=

For example, 7mod4 is:

7mod4=3mod4=1mod4==11mod4=15mod4==3

Input Specification

A single line containing N and M separated by a single space.
109N109
1M106

Output Specification

One line containing the result of NmodM.

Sample Input 1

Copy
7 4

Sample Output 1

Copy
3

Sample Input 2

Copy
15 3

Sample Output 2

Copy
0

Comments

There are no comments at the moment.