Cod sursa(job #1587104)
Utilizator | Data | 1 februarie 2016 20:04:05 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n,p,d,x;
int main()
{fin>>n>>p;
d=1;
x=n;
while(p!=0)
{if(p%2==1){d=(d*x)%1999999973;}
x=(x*x)%1999999973;
p=p/2;
}
fout<<d;
}