Cod sursa(job #318006)
| Utilizator | Data | 26 mai 2009 14:38:17 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.22 kb |
#include<fstream.h>
int main()
{ifstream q("lgput.in");
ofstream w("lgput.out");
long long a,b,pos=1,div=1999999973;
q>>a>>b;
while(b>=1)
{if(b%2==1)
pos=(pos*a)%div;
a=(a*a)%div;
b=b/2;}
w<<pos;
return 0;}