Cod sursa(job #2343743)
| Utilizator | Data | 14 februarie 2019 12:18:46 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
unsigned long long n,x;
unsigned long long MOD;
unsigned long long pow2(int,int);
int main()
{
MOD=1999999973;
fin>>n>>x;
fout<<pow2(n,x);
return 0;
}
unsigned long long pow2(int a,int expo)
{
if (expo==0)
return 1;
if (expo%2==0)
return pow2(a*a%MOD,expo/2);
else
return pow2(a*a%MOD,expo/2)*a%MOD;
}
