Cod sursa(job #2696556)
Utilizator | Data | 16 ianuarie 2021 10:02:32 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long MOD=1999999973;
long long n,p,r;
int main()
{
r=1;
f>>n>>p;
while(p>1)
{
if(p%2==1)
r=(r*n)%MOD*1LL;
n=(n*n)%MOD*1LL;
p=p/2;
}
g<<(n*r)%MOD;
return 0;
}