Cod sursa(job #1925822)
Utilizator | Data | 13 martie 2017 19:02:05 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long a,b,ans=1,mod=1999999973;
int main()
{
in>>a>>b;
while(b) {
if(b%2==0) {
b/=2;
a=(a*a)%mod;
}
else {
ans=(ans*a)%mod;
b--;
}
}
out<<ans;
return 0;
}