Cod sursa(job #1348155)
Utilizator | Data | 19 februarie 2015 15:42:31 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
int N,P,p,r;
fin>>N;
fin>>P;
p=1;
while(P!=1)
{
if(P%2!=0)
{
p=p*N;
}
N=N*N;
P=P/2;
}
N=N*p;
r=N-(N/1999999973);
fout<<r;
return 0;
}