Cod sursa(job #3205833)
Utilizator | Andrei Atomulesei andreiat | Data | 20 februarie 2024 17:20:11 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int N, P;
int f(int x, int n)
{
if(n==0) return 1;
if(n%2==0) return f(x*x, n/2);
else return x*f(x*x, (n-1)/2);
}
int main()
{
fin>>N>>P;
fout<<f(N, P)%1999999973;
return 0;
}