Cod sursa(job #1387504)
Utilizator | Data | 14 martie 2015 12:27:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin ("lgput.in");
ofstream fout("lgput.out");
long long a,p,sol=1;
int main ()
{
fin>>a>>p;
while (p){
if ((p&1)>0)
sol=(sol*a)%MOD;
a=(a*a)%MOD;
p/=2;
}
fout<<sol;
return 0;
}