Cod sursa(job #1396853)
Utilizator | Data | 23 martie 2015 08:45:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
using namespace std;
long long n,prod,t,m;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{int p;
f>>n>>p;
t=n;m=1999999973;prod=1;
while(p)
{if(p%2==1){prod=prod*t%m;;p--;}
else {t=t*t%m;p=p/2;}
}
g<<prod;
return 0;
}