Cod sursa(job #2581179)
Utilizator | Data | 14 martie 2020 16:59:01 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 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*=n;
}
n=(n*n)%MOD;
p/=2;
}
fout<<n*rest;
return 0;
}