Cod sursa(job #2932470)
Utilizator | Data | 2 noiembrie 2022 22:48:26 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
using namespace std;
long long n,p;
const int MOD=1999999973;
ifstream in("lgput.in");
ofstream out("lgput.out");
#define cin in
#define cout out
int putere (int a, int b) {
if (b == 0) return 1;
int h = putere(a, b / 2);
if (b % 2) return h * h * a % MOD;
return h * h % MOD;
}
int main()
{
cin >> n >> p;
cout <<putere(n,p);
return 0;
}