Cod sursa(job #1170866)
Utilizator | Data | 14 aprilie 2014 19:22:26 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,p,x,i;
int main()
{
fin >> n >> p;
x=1;
while (p>0)
{
if (p % 2==1)
{
x*=n;
x%= 1999999973;
p--;
}
n*=n;
p/=2;
}
fout << x;
fin.close();
fout.close();
return 0;
}