Cod sursa(job #2656836)
Utilizator | Data | 8 octombrie 2020 21:06:33 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <bits/stdc++.h>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n,p,rez;
fin>>n>>p;
rez=1;
while(p>0)
{
if(p%2==1)
rez=rez*n%mod;
n=n*n%mod;
p=p/2;
}
fout<<rez;
return 0;
}