Cod sursa(job #1013567)
Utilizator | Data | 21 octombrie 2013 10:22:19 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
using namespace std;
long long p=1,a,b;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>a>>b;
while (b!=0)
{
if (b%2==0)
{
a=(a*a)%1999999973;
b=b/2;
}
else
{
b--;
p=(p*a)%1999999973;
}
}
g<<p%1999999973;
return 0;
}