Cod sursa(job #1347224)
| Utilizator | Data | 18 februarie 2015 20:54:22 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
#define MODULO 1999999973
using namespace std;
ifstream f("lgput.in") ;
ofstream g("lgput.out") ;
unsigned long long Putere(int x,int p)
{
unsigned long long i,aux,sol=1 ;
aux=x ;
for(i=0;(1<<i)<=p;i++)
{
if((1<<i)&p)
sol=(sol*aux)%MODULO ;
aux=(aux*aux)%MODULO ;
}
return sol ;
}
int main()
{
unsigned long long z,w ;
f>>z>>w ;
g<<Putere(z,w) ;
return 0;
}
