| Task: | Exponentiation |
| Sender: | discape |
| Submission time: | 2025-11-16 21:09:42 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | details |
| #2 | ACCEPTED | 0.11 s | details |
| #3 | ACCEPTED | 0.10 s | details |
Code
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#ifndef DO_DBG
#define dbg(...)
#endif
template <typename... Args> void read(Args&... args) { ((cin >> args), ...); }
template <typename T> using v = vector<T>;
typedef long long ll; typedef long double ld; typedef v<ll> vi; typedef pair<ll, ll> pii; // this template is kactl compatible
typedef complex<ll> Pi; typedef complex<ld> Pr;
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin.exceptions(cin.failbit);
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rp(n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sq(x) ((x)*(x))
#define d(...) ll __VA_ARGS__; read(__VA_ARGS__);
#define dv(x, n) vi x(n); for (size_t i = 0; i < n; i++) cin >> x[i];
#define even(x) ((x)%2==0)
#define odd(x) ((x)%2!=0)
#define sz(s) ((ll)s.size())
#define dist(v,it) distance(v.begin(),it)
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).imag()
#define idxof(a, elem) dist(a, find(all(a), elem))
constexpr int MOD = 1e9 + 7;
ll ipow(ll a,int b){ll r=1;for(;b;b>>=1,a=(a*a)%MOD)if(b&1)r=(r*a)%MOD;return r;}
// clang-format on
int main() {
ios;
d(n);
while (n--) {
d(a, b);
cout << ipow(a, b) << '\n';
}
}
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 ... Truncated |
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 ... Truncated |
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 ... Truncated |
