Cod sursa(job #3207675)
Utilizator | Iordache Eduard EdyIordache | Data | 26 februarie 2024 18:38:23 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
using namespace std;
#define mod 1999999973
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main() {
long long n, p, x;
fin>>n>>p;
x = 1;
while (p) {
if (p % 2 == 1) x = x * n % mod;
n = n * n % mod;
p /= 2;
}
fout<<x % mod;
return 0;
}