Cod sursa(job #2563921)
Utilizator | Data | 1 martie 2020 16:11:32 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define mod 1999999973
long long n,p;
int f(int n,int p)
{
long long r=1;
while(p!=0)
{
if(p%2==1)
{
r=(1LL*r*n)%mod;
}
n=n*n;
p=p/2;
}
return r;
}
int main ()
{
fin>>n>>p;
fout<<f(n,p);
fin.close();
fout.close();
return 0;
}