Cod sursa(job #2969341)
Utilizator | Data | 22 ianuarie 2023 21:25:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
#define M 1999999973
#define ull unsigned long long
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ull putere(ull n,ull p)
{
if(p==0)
return 1;
ull A = 1;
while(p)
{
if(p%2==1)
A = (A * n) % M;
n = (n * n) % M;
p /= 2;
}
return A % M;
}
int main()
{
ull n,p;
fin>>n>>p;
fout<<putere(n,p);
return 0;
}