Computer Science, asked by dwaragesh619, 14 hours ago

Output Format
• The body of main() should be left unaltered. Complete the
definition of method 'solve' which should return the answer to
the problem. Also, implement class 'Calculator that performs all
modulo operations.
21
22 - protec
23
//
24 }
25 }
26
27- class MyCla
28 // ALZ
29 // of
30
31 - public
32
//
33 }
34 }
Evaluation Parameters
Sample Input 1
1
5 2
Sample Output 1

Answers

Answered by ethicalhacker7049
0

Answer:

n most programming competitions, we are required to answer the result in 10^9+7 modulo. The reason behind this is, if problem constraints are large integers, only efficient algorithms can solve them in an allowed limited time.

What is modulo operation:

The remainder obtained after the division operation on two operands is known as modulo operation. The operator for doing modulus operation is ‘%’. For ex: a % b = c which means, when a is divided by b it gives the remainder c, 7%2 = 1, 17%3 = 2.

Why do we need modulo:

The reason of taking Mod is to prevent integer overflows. The largest integer data type in C/C++ is unsigned long long int which is of 64 bit and can handle integer from 0 to (2^64 – 1). But in some problems where the growth rate of output is very high, this high range of unsigned long long may be insufficient.

Suppose in a 64 bit variable ‘A’, 2^62 is stored and in another 64 bit variable ‘B’, 2^63 is stored. When we multiply A and B, the system does not give a runtime error or exception. It just does some bogus computation and stores the bogus result because the bit size of the result comes after multiplication overflows

Explanation:

Similar questions