Cod sursa(job #3002418)
Utilizator | Data | 14 martie 2023 19:06:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
#define m 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long a,p;
int expr(long long a, long long p)
{
int r=1;
while(p)
{
if(p%2==1)r=(r*a)%m;
a=(a*a)%m;
p/=2;
}
return r;
}
int main()
{
fin>>a>>p;
fout<<expr(a,p)%m;
return 0;
}