SimpleMathProblem
TCO19 SRM 737 · 2018-09-18 · by Blue.Mary
TCO19 SRM 737 · 2018-09-18 · by Blue.Mary · Math
Problem Statement
Problem Statement
You are given four positive integers a,b,c and m. Let x = bc. Calculate and return the following value: (ax mod m).
Constraints
- a,b,c and m will each be between 1 and 737,373,737, inclusive.
Examples
0)
1 1 1 737 Returns: 1
1^(1^1) modulo 737 is 1.
1)
3 7 3 123456789 Returns: 63564408
First we get that x = 7^3 = 343. Then we compute the answer: (3^x modulo 123456789).
2)
12 34 56 78 Returns: 66
3)
3737373 7373737 37373 737373737 Returns: 214080347
4)
1 1 1 2 Returns: 1
57)
2 10 10 1024 Returns: 0
2^(10^10) is divisible by 1024, hence the remainder is zero.
58)
47 53 912 1 Returns: 0
Any integer modulo 1 is zero.
Submissions are judged against all 72 archived test cases, of which 7 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class SimpleMathProblem with a public method int calculate(int a, int b, int c, int m) · 72 test cases · 2 s / 256 MB per case