Cod sursa(job #2274014)
| Utilizator | Data | 1 noiembrie 2018 11:04:48 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <queue>
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
const long long mod = 1999999973;
long long lgput(long long power, long long exp) {
if ( exp == 0)
return 1;
long long t = lgput(power,exp/ 2),x;
x = 1LL * t * t % mod;
if ( exp & 1)
x = 1LL * x * power;
return x;
}
int main() {
long long a,b;
fin >> a >> b;
fout << lgput(a,b);
}
