Pagini recente » Cod sursa (job #2621580) | Cod sursa (job #2492865) | Cod sursa (job #563311) | Cod sursa (job #1148796) | Cod sursa (job #342619)
Cod sursa(job #342619)
#include <stdio.h>
long p,q,a[100002],b[100002],i,k;
int main(){
FILE *f,*g;
f=fopen("gfact.in","r");
g=fopen("gfact.out","w");
fscanf(f,"%ld%ld",&p,&q);
for(i=1;i<=100000;i++){
a[i]=0;
b[i]=0;
}
k=0;
if(p%2==0){
a[++k]=2;
while(p%2==0){
b[k]++;
p/=2;
}
}
i=3;
do{
if(p%i==0){
a[++k]=i;
while(p%i==0){
b[k]++;
p/=i;
}
}
i+=2;
}while(p!=1);
long long nr=a[k];
for(i=1;i<=b[k];i++)
nr*=a[k];
fprintf(g,"%lld\n",nr);
fclose(f);
fclose(g);
return 0;
}