Cod sursa(job #3124048)
Utilizator | Data | 26 aprilie 2023 19:08:29 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p;
int main()
{
fin >> n >> p;
int r = 1;
while(p != 0)
{
if(p%2)
{
r = r*n%MOD;
}
n = n*n%MOD;
p /= 2;
}
fout << r;
}