Cod sursa(job #2873324)
Utilizator | Data | 19 martie 2022 09:32:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
#define N 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
int n,p,r=1;
fin>>n>>p;
while(p)
{
if(p%2!=0)
{
r=(r*n)%N;
}
n=(n*n)%N;
p/=2;
}
fout<<r%N;
return 0;
}