CSES - Aalto Competitive Programming 2024 - wk11 - Homework - Results
Submission details
Task:Exponentiation
Sender:Rasse
Submission time:2024-11-14 09:18:37 +0200
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.02 sdetails
#2ACCEPTED0.55 sdetails
#3ACCEPTED0.58 sdetails

Code

#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <climits>
#include <cmath>
#include <functional>
#include <type_traits>
#include <fstream>
#include <bitset>
#include <complex>
#include <iomanip>
 
#define int long long
using namespace std;
 
#define cross(x, y) (((x)*conj(y)).imag())
#define mag(x) (sqrt(x.imag() * x.imag() + x.real() * x.real())
#define sign(v) ((0 < (v)) - ((v) < 0))

unordered_map<string, long double> mp;

int mod = 1e9+7;

int p(int a, int b)
{
    if (b == 0) return 1;
    else if (b % 2 == 0) { int r = p(a, b/2); return (r*r) % mod; }
    else return (p(a, b-1)*a) % mod; 
}

void solve()
{
    int a, b;
    cin >> a >> b;
    cout << p(a, b) << '\n';
}
 
 
signed main()
{
    ios::sync_with_stdio(0);
    cout.precision(25);
    //setprecision(10);
    //cin.tie(0);
 
    int t = 1;
 
    cin >> t;
    //ifstream f("testcase.txt");
    //cin.rdbuf(f.rdbuf());
 
    for (int i = 0; i < t; i++)
        solve();
}

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
...