Mai intai trebuie sa te autentifici.
Cod sursa(job #2040892)
Utilizator | Data | 16 octombrie 2017 17:32:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n,p,x,y;
int main()
{
fin>>n>>p;
x=n;
y=1;
while(p>0)
{
if(p%2==1)
{
y=(y*x)%1999999973;
}
x=(x*x)%1999999973;
p=p/2;
}
fout<<y;
return 0;
}