Mai intai trebuie sa te autentifici.
Cod sursa(job #534864)
Utilizator | Data | 16 februarie 2011 13:02:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 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) % 1999999973;
if (b % 2 == 0)
return (c * c) % 1999999973;
else return (c * c * a) % 1999999973;
}
int main()
{
ifstream f ("lgput.in");
ofstream g ("lgput.out");
f >> n >> p;
g << powe (n , p);
return 0;
}