Cod sursa(job #2569473)
Utilizator | Data | 4 martie 2020 12:17:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#include <bitset>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int m = 1999999973;
int n, p;
long long ans = 1;
int main()
{
in >> n >> p;
while(p)
{
if(p & 1)
ans = (1ll * ans * n) % m;
n = (1ll * n * n) % m;
p /= 2;
}
out << ans;
return 0;
}