Cod sursa(job #3123465)
| Utilizator | Data | 23 aprilie 2023 20:49:05 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
#define lli long long int
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const lli MOD = 1999999973;
lli putere(lli a, lli n) {
lli ans = 1LL;
while(n > 0) {
if(n % 2 != 0) {
ans = (ans * a) % MOD;
}
a = (a * a) % MOD;
n /= 2;
}
return ans;
}
lli n, p;
int main() {
fin >> n >> p;
fout << putere(n, p);
return 0;
}