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