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