Cod sursa(job #814815)
Utilizator | Data | 16 noiembrie 2012 09:43:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include <fstream>
#define LL long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
LL b,n,r,p;
const int MOD=1999999973;
int main()
{
f>>n>>p;
for(b=n,r=1;p;p>>=1)
{
if(p&1)
r=(r*b)%MOD;
b=(b*b)%MOD;
}
g<<r<<'\n';
return 0;
}