Cod sursa(job #1189759)
Utilizator | Data | 23 mai 2014 14:08:19 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long p,x;
int n;
int main()
{f>>x>>n;
p=1;
while(n>0){
if(n%2!=0)
p=p*x%1999999973;
x=x*x%1999999973;
n=n/2;}
g<<p%1999999973;
return 0;
}