Cod sursa(job #1168798)
Utilizator | Data | 9 aprilie 2014 16:50:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <fstream>
using namespace std;
const int MOD= 1999999973;
ifstream fin("lgput.in");
ofstream fout ("lgput.out");
int Pow(int a,int b)
{
int p=1;
while(b)
{
if(b&1)
p=1LL*p*a%MOD;
a=1LL*a*a%MOD;
b>>=1;
}
return p;
}
int main()
{
int a,b;
fin>>a>>b;
fout<<Pow(a,b);
fin.close();
fout.close();
return 0;
}