题目链接
Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1 * p2^k2 *…*pm^km.
Input Specification:
Each input file contains one test case which gives a positive integer N in the range of long int.
Output Specification:
Factor N in the format N = p1^k1 * p2^k2 *…*pm^km, where pi's are prime factors of N in increasing order, and the exponent ki is the number of pi -- hence when there is only one pi, ki is 1 and must NOT be printed out.(坑爹,这最后一句不是说满足情况不输出,可答案是要输出的,害我吓考虑2个case没过)
Sample Input:
97532468
Sample Output:
97532468=2^2*11*17*101*1291 ---------------------------------------------------华丽的分割线---------------------------------------------------------------------------------------------
1 #include2 #include 3 using namespace std; 4 const int maxn=100005; 5 int prime[maxn],pnum=0; 6 bool p[maxn]={ 0}; 7 void Find_Prime(){ 8 p[0]=p[1]=true; 9 for(int i=2;i 0)45 printf(" *");46 if(fac[i].cnt> 1)47 printf("%d^%d",fac[i].x,fac[i].cnt);48 else49 printf("%d",fac[i].x);50 }51 printf("\n");52 }53 int main()54 {55 Find_Prime();56 int n;57 while(scanf("%d",&n)!=EOF){58 if(n==1)59 printf("1=1\n");60 else{61 PrimeFactor(n);62 Print_fac(n);63 }64 65 /*66 int a=(1<<31)-1;67 cout< <