Cod sursa(job #2812308)
| Utilizator | Data | 4 decembrie 2021 12:39:44 | |
|---|---|---|---|
| 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>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long fast_exp(unsigned int a, unsigned int b)
{
long long ans = 1;
while(b)
{
if(b & 1LL)
ans = (ans * a) % mod;
a = (1LL * a * a) % mod;
b >>= 1LL;
}
return ans;
}
int main()
{
unsigned int n, p;
fin>>n>>p;
fout<<fast_exp(n, p);
return 0;
}
