Cod sursa(job #1951649)
Utilizator | Fogel Peter fogel.peter | Data | 3 aprilie 2017 18:59:15 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long a,b;
int hatv(long long b)
{
if(b==1) return a;
else
{
long long k=hatv(b/2);
if(b%2==0) return ((k%1999999973)*(k%1999999973))%1999999973;
else return ((k%1999999973)*(k%1999999973)*a)%1999999973;
}
}
int main()
{
f>>a>>b;
g<<hatv(b);
return 0;
}