Cod sursa(job #1382675)
Utilizator | Data | 9 martie 2015 13:47:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,p,sol=1;
int main()
{
fin>>n>>p;
while(p)
{
if(p & 1)
sol = (sol * n)%MOD;
n = (n * n)%MOD;
p = p>>1;
}
fout<<sol<<'\n';
return 0;
}