Cod sursa(job #2162204)
Utilizator | Noroc Andrei Mihail andreiutu111 | Data | 12 martie 2018 09:04:45 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long N,P;
int main()
{
f>>N>>P;
long long rez=1;
while(P)
if(P%2==1)rez=(rez*N)%1999999973,--P;
else N*=N,P/=2;
g<<rez;
return 0;
}