Cod sursa(job #3250628)
| Utilizator | Data | 22 octombrie 2024 15:45:04 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
long long pwr(unsigned int a, unsigned int b)
{
int p = 1;
while(b > 0)
{
if(b % 2 == 0)
p = 1LL * p * a % MOD;
a = 1LL * a * a % MOD;
b /= 2;
}
return p;
}
int main()
{
unsigned int n, p;
long long sol;
fin >> n >> p;
n %= MOD;
sol = pwr(n, p);
fout << sol;
return 0;
}
