Cod sursa(job #3298762)
| Utilizator | Data | 1 iunie 2025 14:44:59 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
unsigned long long exp(float x, int n) {
if (n < 0)
return exp(1.0 / x, -n);
if (n == 0)
return 1;
if (n % 2 == 0)
return exp(x * x, n / 2);
if (n % 2 == 1)
return x * exp(x * x, n / 2);
}
int main(void) {
unsigned long long n, p;
f >> n >> p;
unsigned long long r = exp(n, p);
g << r % 1999999973;
return 0;
}