Cod sursa(job #3132870)
Utilizator | Data | 24 mai 2023 00:35:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
using namespace std;
#define MOD 1999999973
ifstream in("lgput.in");
ofstream out("lgput.out");
int exp_log(int x, int n)
{
if(n == 0) return 1;
if(n%2) return x*exp_log(x*x, n/2);
return exp_log(x*x, n/2);
}
int main()
{
int n, p;
in >> n >> p;
out << exp_log(n, p) %MOD;
return 0;
}