Cod sursa(job #1919767)
| Utilizator | Data | 9 martie 2017 20:59:57 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#define MOD 1999999973;
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long base,exp;
long long LogExp(long long base,long long exp)
{
long long act=base,out=1;
for(long long p=1;p<=exp;p<<=1)
{
if(p&exp)
out=(out*act)%MOD;
act=(act*act)%MOD;
}
return out;
}
int main()
{
in>>base>>exp;
out<<LogExp(base,exp);
return 0;
}
