Cod sursa(job #1513060)
Utilizator | Data | 28 octombrie 2015 22:29:08 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
unsigned long long a,b,c,r=1;
int main()
{
fin>>a>>b;
c=1999999973;
while(b>1)
{
if(b%2==0)
{
b>>=1;
a=(a*a)%c;
}
else
{
b--;
r=(r*a)%c;
}
}
fout<<(a*r)%c;
}