Cod sursa(job #2682171)

Utilizator andrei.florea0405Florea Andrei-Bogdan andrei.florea0405 Data 7 decembrie 2020 22:40:06
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.65 kb
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define MOD 1999999973

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

ifstream fin("lgput.in");
ofstream fout("lgput.out");

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, p;

    fin >> n >> p;

    int rez = 1;
    while (p) {
        if (p & 1) {
            rez = (rez * n) % MOD;
        }
        n = (n * n) % MOD;
        p >>= 1;
    }


    fout << rez << "\n";
    
    return 0;
}