Cod sursa(job #2586721)
Utilizator | Data | 21 martie 2020 13:40:31 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD=1999999973;
long long n,p;
int main()
{
fin>>n>>p;
int rest=1;
for(;p>1;)
{
if(p%2==1)
{
rest=(rest*n)%MOD;
}
n=(n*n)%MOD;
p/=2;
}
fout<<n*rest;
return 0;
}