Submission

Status:

[PPPPPPPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: Phat12

Problemset: ยกกำลัง

Language: cpp

Time: 0.030 second

Submitted On: 2025-08-29 14:12:54

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1e9+7;
int expo(int a,int b){
    if (b==0) return 1;
    int temp = expo((a*a)%MOD,b/2)%MOD;
    if (b%2==0){
        return temp;
    }
    return (temp*a)%MOD;
}
int32_t main() {
	int t;
	cin >> t;
	while (t--){
	    int a,b;
	    cin >> a >> b;
	    cout << expo(a,b) << '\n';
	}
	

}