Cod sursa(job #3325303)
| Utilizator | Data | 25 noiembrie 2025 11:17:37 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.38 kb |
#include<fstream>
#include<iostream>
using namespace std;
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define mod 1999999973
unsigned long long n, p;
fin >> n >> p;
n %= mod;
p %= mod;
while (p) {
if (p % 2) {
n *= p, n %= mod, p--;
}
else {
n %= mod;
n *= n;
n %= mod;
p /= 2;
}
}
fout << n;
return 0;
}