Cod sursa(job #1372836)
Utilizator | Data | 4 martie 2015 15:31:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
using namespace std;
long long x,y,a=1;
int main()
{
FILE *f=fopen("lgput.in","r");
FILE *g=fopen("lgput.out","w");
fscanf(f,"%lld %lld",&x,&y);
while(y)
{
if(y%2==1)
{
a*=x;
a%=1999999973;
}
x*=x;
x%=1999999973;
y/=2;
}
fprintf(g,"%lld\n",a);
return 0;
}