Cod sursa(job #558218)
Utilizator | Data | 17 martie 2011 09:55:46 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int modulo=1999999973;
int main()
{
int n,p,rez=1,r,x,px;
fin>>n>>x;
px=x;
while(n)
{
r=n%2;
if(r)
rez=(rez*px)%modulo;
px=px*px; n/=2;
}
fout<<rez;
fout.close();
return 0;
}