Cod sursa(job #3244839)
Utilizator | Data | 26 septembrie 2024 17:57:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long Expolog(long long a,long long n,int mod)
{
long long p=1;
while(n>0)
{
if(n%2==1)p=p*a%mod;
a=a*a%mod;
n/=2;
}
return p;
}
int main()
{
long long a,n;
fin>>a>>n;
fout<<Expolog(a,n,1999999973);
return 0;
}