Cod sursa(job #1584570)
Utilizator | Data | 30 ianuarie 2016 11:55:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <fstream>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
int main ()
{
int m=1999999973;
long long N,P;
f>>N>>P;
long a=1;
while(P!=0)
{
if(P%2==1) a*=N;
P/=2;
N*=N;
a%=m;
}
g<<a;
return 0;
}