Cod sursa(job #2211711)
Utilizator | Data | 11 iunie 2018 15:17:26 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
const int MOD = 1999999973;
int n, p;
int lgput (long long a, int b) {
if (b == 0) return 1;
long long x = lgput(a, b / 2);
if (b % 2 == 0)
return x * x % MOD;
else
return x * x % MOD * a % MOD;
}
int main()
{
fin >> n >> p;
fout << lgput(n, p);
return 0;
}