Cod sursa(job #867949)
Utilizator | Data | 30 ianuarie 2013 14:50:02 | |
---|---|---|---|
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");
unsigned int power (unsigned int a, unsigned int b)
{
int 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;
}