0198. Simple Calculations

Input file name: calc.in
Output file name: calc.out
Time limit: 500 ms
Memory limit: 32 megabytes

You have to calculate the function F(n,k) = (22n + 1) mod k.

Input file

Input file contains two integer numbers n and k separated by spaces (0 ≤ n ≤ 231-1, 1 ≤ k ≤ 106).

Output file

You must output F(n,k).

Examples:

calc.incalc.out
0 43


Source: Petrozavodsk Summer 2003. Saratov SU Contest, Wednesday, August 27

Discuss       Submit a solution



Printable version