Cod sursa(job #534857)
Utilizator | Data | 16 februarie 2011 12:56:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
long long n , p;
long long powe (long long a , long long b)
{
if (b == 0)
return 1;
long long c = powe(a , b/2);
if (b % 2 == 0)
return c * c;
else return c * c * a;
}
int main()
{
ifstream f ("lgput.in");
ofstream g ("lgput.out");
f >> n >> p;
g << powe (n , p) % 1999999973;
return 0;
}