Cod sursa(job #730123)
Utilizator | Data | 4 aprilie 2012 19:14:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include<fstream>
#define M 1999999973
using namespace std;
int a,b;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long lgg(long long a,long long b)
{
long long p=1;
while(b>1)
{
if(b%2==1)
a=(p*a)%M;
a=(a*a)%M;
b/=2;
}
return (a*p)%M;
}
int main()
{
f>>a>>b;
g<<lgg(a,b);
f.close();
g.close();
return 0;
}