Cod sursa(job #779485)
Utilizator | Data | 17 august 2012 19:56:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
#define NRM 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,P=1;
int main()
{
int i,j;
f>>n>>p;
P=n;
for(i=2;p>1;i++){
while(!(p%i)){
for(j=1;j<i;j++)
P=(P*n)%NRM;
p/=i;
n=P;}}
g<<P;
f.close();
g.close();
return 0;
}