[板子]质因数分解

include

include

include

include

include

include

define ll long long

define maxn 1005

using namespace std;
int p[maxn],c[maxn],tot;
void devide(int n){
tot=0;
for(int i=2;i<=sqrt(n);++i){
if(n%i==0){
++tot;
p[tot]=i;
c[tot]=0;
while(n%i==0){
n/=i;
++c[tot];
}
}
}
if(n>1){
++tot;
p[tot]=n;
c[tot]=1;
}
return;
}
int main(){
int n;
scanf("%d",&n);
devide(n);
for(int i=1;i<=tot;++i){
printf("%d %d\n",p[i],c[i]);
}
return 0;
}

猜你喜欢

转载自www.cnblogs.com/theOldChun/p/9927094.html