Cod sursa(job #613508)
| Utilizator | Data | 28 septembrie 2011 17:53:30 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include<fstream>
using namespace std;
#define c 1999999973
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long Putere( long long a, long long b );
int main()
{
long long x, y;
fin >> x >> y;
fout << Putere( x, y ) % c;
fin.close();
fout.close();
return 0;
}
long long Putere( long long a, long long b)
{
if( b == 0 )
return 1;
if( b % 2 == 0 )
return Putere( (a*a)%c, b/2 ) % c;
else
return (a * (Putere(a*a, b/2)%c))%c;
}
