MeetCode
Home
Doubts
Why is my C function not returning the …
Solved
1
49
Ask Doubt
View All Doubts
Solvers Leaderboard
Tutorials
Quiz
All Tests
Leaderboard
My Tasks
User Login
Dark
Enable Notifications
Toggle navigation
Fast Power Mod Function
Programming Interview
Hard
4 views
Back to Questions
View Answer
0
Previous
All Subset Sums
Hard
P
Next
Kth Switch Toggle
Hard
N
Problem Description
We have {x}.
Input Format
One line: a b m.
Output Format
One integer ans.
Sample Test Case
Input:
2 10 1000
Output:
24
Constraints
0
Official Solution
import sys p=sys.stdin.read().strip().split() if len(p)<3: sys.exit(0) a=int(p[0]); b=int(p[1]); m=int(p[2]) def modpow(x,y,mod): x%=mod res=1%mod while y>0: if y&1: res=(res*x)%mod x=(x*x)%mod y//=2 return res sys.stdout.write(str(modpow(a,b,m)))
Please
login
to submit solutions and comments.
Solutions (0)
No solutions submitted yet. Be the first!
Discussion (0)
No comments yet. Start the discussion!
Prev
Next
Fullscreen Editor
0 lines • 0 chars
Esc close • Tab indent
No comments yet. Start the discussion!