Cod sursa(job #3258315)
| Utilizator | Data | 21 noiembrie 2024 21:11:12 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int MOD = 1999999973;
int powlg (int a, int b)
{
int rez = 1;
while (b != 0)
{
if (b % 2 == 1)
{
rez = 1LL * rez * a % MOD;
}
a = 1LL * a * a % MOD;
b /= 2;
}
return rez;
}
int main()
{
ifstream f ("lgput.in");
ofstream g ("lgput.out");
int n, p;
f >> n >> p;
g << powlg (n, p);
return 0;
}
