Cod sursa(job #3203016)
Utilizator | Data | 12 februarie 2024 21:30:59 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long lgput(int n, int p)
{
long long r=1;
while(p)
{
if(p%2)
r*=n%MOD;
n=n*n%MOD;
p/=2;
}
return r%MOD;
}
int main()
{
int n, p;
fin>>n>>p;
fout<<lgput(n, p);
return 0;
}