Cod sursa(job #2373104)
Utilizator | Data | 7 martie 2019 12:16:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <bits/stdc++.h>
#define modulo 1999999973
using namespace std;
ifstream f("lgput.in"); ofstream g("lgput.out");
long long x,p,ans=1;
int main()
{ f>>x>>p;
while(p>0)
{ if(p%2==1) ans=(ans*x)%modulo;
x=(x*x)%modulo;
p/=2;
}
g<<ans%modulo;
return 0;
}