Cod sursa(job #2587976)
| Utilizator | Data | 23 martie 2020 23:04:09 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
const int Rest=1999999973;
int main()
{
int n,k,r;
ifstream in("lgput.in");
ofstream out("lgput.out");
in>>n>>k;
r=1;
while (k>1)
{
if (k&1)
r=(1LL*n*r)%Rest;
n*=(1LL*n)%Rest;
k/=2;
}
out<<r;
return 0;
}
