⌘K
Flycodx

Flipkart Discount Fast Exponentiation Mod

Flipkart Discount Fast Exponentiation Mod

MediumMath0% accepted

Flipkart discounts are computed as base^exp mod prime. Given base, exp, and mod (prime), compute (base^exp) % mod efficiently. exp can be up to 10^18.

Approach

Compute (base^exp) % mod using fast binary exponentiation in O(log exp).

Input

2 10

Output

1024
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3