Cod sursa(job #1233541)
Utilizator | Data | 25 septembrie 2014 18:02:33 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
using namespace std;
int main()
{
long long n,p,x,p1;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>x;
p=1;
while(x!=0)
{
p=p%1999999973;
n=n%1999999973;
if (x%2==1)
{
x--;
p=p*n;
}
n=n*n;
x/=2;
}
fout<<p<<"\n";
fin.close();
fout.close();
return 0;
}