Cod sursa(job #1552179)
Utilizator | Data | 17 decembrie 2015 12:29:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long x,N,n,p;
int main()
{fin >>x>>n;
p=1;
N=1999999973;
while (n>0)
{if (n%2)
{
p=p*x%N;
n=n-1;
}
x=x*x%N;
n=n/2;
}
fout<<p;
return 0;
}