View Code of Problem 91

#include<stdio.h>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){

	int n;
	scanf("%d",&n);
	int b[1000],k=0;
	for(int i=2;i<=n;i++){//判断素数存入数组 
		int j=2;
		while(i%j!=0){
			j++;
		}
		if(j==i)    b[k++]=i;
	}
	printf("%d=", n);
	int count=0;
	for(int l=0;l<k;l++){
		while(n%b[l]==0){
			if(count==0)
			printf("%d", b[l]);
			else
			printf("*%d", b[l]);
			n=n/b[l];
			count++;
		}
	}
   
	
	return 0;
}

Double click to view unformatted code.


Back to problem 91