Mai intai trebuie sa te autentifici.
Cod sursa(job #1342697)
Utilizator | Data | 14 februarie 2015 13:53:06 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int x,n,p,prod;
fin>>x>>n;
x=x%1999999973;
prod=x;
while(n>1)
{
if(n%2==0)
{
prod=prod*prod;
n=n/2;}
else
{
prod=prod*x;
p=p-1;
}
prod=prod%1999999973;
}
fout<<prod;
return 0;
}