CSES - Aalto Competitive Programming 2024 - wk11 - Homework - Results
Submission details
Task:Exponentiation
Sender:HFalke
Submission time:2024-11-16 21:49:53 +0200
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.26 sdetails
#3ACCEPTED0.30 sdetails

Code

#include <bits/stdc++.h>

using namespace std;

//Definitions for quicker writing
#define REP(i,a,b) for (int i = a; i < b; i++)
#define clz __builtin_clz
#define ctz __builtin_ctz
#define popct __builtin_popcount
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define X real()
#define Y imag()

//Typedefs for quicker writing
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
typedef pair<long long, long long> pl;
typedef complex<long long> po;

//Max values
const long long lmx = LLONG_MAX;
const int imx = INT_MAX;

ll modpow(ll x, ll n, ll m) {
    if (n == 0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}

int main() {
	//IO optimization
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	//Input definition
    ll n;
    cin >> n;

	//Main part
	ll a,b;
    REP(i,0,n){
	    cin >> a >> b;
	    cout << modpow(a,b,1000000007) << "\n";
    }
		
	//Return
	return 0;

}

Test details

Test 1

Verdict: ACCEPTED

input
10201
0 0
0 1
0 2
0 3
...

correct output
1
0
0
0
0
...

user output
1
0
0
0
0
...

Test 2

Verdict: ACCEPTED

input
200000
129612095 411099530
241615980 487174929
60862511 511830781
758816482 982657640
...

correct output
276067146
838400234
148093882
546897305
467086232
...

user output
276067146
838400234
148093882
546897305
467086232
...

Test 3

Verdict: ACCEPTED

input
200000
692427692 536870911
252480658 536870911
505090334 536870911
27194853 536870911
...

correct output
940305728
707431813
917260341
908974199
375947818
...

user output
940305728
707431813
917260341
908974199
375947818
...