Exponentiation
면접 대비시간 제한3초메모리 제한1024 MB
x + 1/x = alpha일 때 x^beta + 1/x^beta를 m으로 나눈 나머지를 구한다. 이 값은 체비쇼프 점화식을 따른다.
문제
Exponentiation is a mathematical operation that involves raising a base number to a certain exponent to obtain a result. In the expression , where is the base and is the exponent, it means multiplying by itself times. The result of this operation is called the exponentiation of to the -th power. For examples, and . In these examples, is the base, is the exponent in the first case, and is the base, and is the exponent in the second case. Exponentiation is a fundamental operation in mathematics and is commonly used in various contexts, such as solving equations, and cryptography.
In many cryptographic algorithms, particularly those based on number theory like RSA (Rivest-Shamir-Adleman) and Diffie-Hellman, modular exponentiation is a fundamental operation. Modular exponentiation involves raising a base to an exponent modulo a modulus. This operation is computationally intensive but relatively easy to perform, even for very large numbers.
Let where is a positive integer. Please write a program to compute for given positive integers and .
입력
The input has only one line, and it contains three space-separated positive integers , and . , and are positive integers less than .
출력
Outout . You may assume is an integer. If there are multiple solutions, you may output any of them in the range from to .
힌트
can be a complex number. For example, is either or if . However, is always an integer in this problem.