Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int MOD = (int) 1e9 + 7;
- int Power(int a, int b) {
- if (b == 0) {
- return 1;
- }
- if (b == 1) {
- return a;
- }
- int ret = Power(a, b / 2);
- if (b % 2 == 0) {
- return (ret * ret) % MOD;
- } else {
- return ((ret * ret) % MOD * a) % MOD;
- }
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(0);
- int x, y;
- cin >> x >> y;
- cout << Power(x, y) << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement