Cod sursa(job #784441)
Utilizator | Data | 5 septembrie 2012 19:12:13 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
long long n,p,r;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>n>>p;
r=1;
while(p>0)
{ if(p%2)
r=(r*n)%MOD;
n=(n*n)%MOD;
p=p/2;}
g<<r;
}