Cod sursa(job #304570)
Utilizator | Data | 14 aprilie 2009 00:47:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.25 kb |
#include<fstream.h>
#define c 1999999973
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long a, b, rez=1;
int main()
{
fin>>a>>b;
while(b)
{
if(b%2==1)
rez=rez*a%c;
a=a*a%c;
b=b/2;
}
fout<<rez;
return 0;
}