Cod sursa(job #867951)
Utilizator | Data | 30 ianuarie 2013 14:52:37 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
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 power (unsigned int a, unsigned int b)
{
long long x;
if (b==0) return 1;
x=power(a,b/2);
if (b%2) return (x*x*a)%1999999973;
return (x*x)%1999999973;
}
int main ()
{
unsigned int a,b;
fin>>a>>b;
fout<<power(a,b)%1999999973;
}