P6959 [NEERC 2017] Hack

Description

Heidi is analyzing a peculiar device. This device takes an a as input and computes $a^d(mod n)$ using thefollowing pseudocode and some integers $d$ and $n$ stored in this device: ``` modPow(a, d, n) { r = 1; for (i = 0; i < 60; ++i) { if ((d & (1

Input Format

N/A

Output Format

N/A