Cod sursa(job #1074100)
Utilizator | Data | 7 ianuarie 2014 09:27:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.27 kb |
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const int MOD=1999999973;
long long n,p,r=1;
int main()
{ f>>n>>p;
while(p)
{ if(p&1) r=r*n%MOD;
n=n*n%MOD; p=(p>>1);
}
g<<r<<"\n"; g.close(); return 0;
}