Cod sursa(job #1512920)
Utilizator | Data | 28 octombrie 2015 19:41:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include<fstream>
#define ull unsigned long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ull a,b,c,r;
int main()
{
f>>a>>b;
c=1999999973;
ull r=1;
while(b>1)
{
if(b%2==0)
{
b>>=1;
a=(a*a)%c;
}
else
{
b--;
r=(r*a)%c;
}
}
g<<(a*r)%c;
return 0;
}