Lũy Thừa Nhị Phân (Binary Exponentiation A^B mod M)
Points
25
AC Rate
0.0%
Time limit
1.0 s
Memory limit
256M
Group
number
Đề bài
Cho hai số nguyên không âm A, B (0 ≤ A, B ≤ 10^18, A + B > 0). Hãy tính A^B mod 1000000007 bằng thuật toán lũy thừa nhị phân trong O(log B).
Dữ liệu vào (Input)
- Một dòng duy nhất chứa hai số nguyên
AvàB.
Dữ liệu ra (Output)
- In ra giá trị
A^B mod 1000000007.
Ví dụ mẫu
Sample Input 1
2 10
Sample Output 1
1024
Sample Input 2
3 20
Sample Output 2
486784380
Community Discussion