Cod sursa(job #2574957)
Utilizator | Data | 6 martie 2020 10:54:39 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <bits/stdc++.h>
#define M 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,sol=1;
int main()
{ f>>n>>p;
for(long long aux=n; p; p>>=1)
{ if(p&1)
sol=(sol%M*aux%M)%M;
aux=(aux%M*aux%M)%M;
}
g<<sol;
g.close(); return 0;
}