Cod sursa(job #2732807)
| Utilizator | Data | 29 martie 2021 13:26:35 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#define MOD 1999999973
#define FIN "lgput.in"
#define FOUT "lgput.out"
#define LL long long
using namespace std;
LL pow(LL base, LL exp) {
LL ans = 1;
while(exp) {
if(exp & 1) {
ans *= base;
}
base *= base;
exp >>= 1;
}
return ans % MOD;
}
int main(int argc, char const *argv[])
{
LL a, b;
ifstream fin(FIN);
ofstream fout(FOUT);
fin>>a>>b;
fout<<pow(a,b);
return 0;
}