HDU 1164 分解成素数乘积的形式

来源:互联网 发布:什么是网络平台 编辑:程序博客网 时间:2024/06/06 03:45
#include <iostream>using namespace std;int a[20];int getPrimeNum(int x){int cnt = 0;for(int  i = 2; i <= x; i++){while(x % i == 0){a[cnt++] = i;x  = x / i;}}return cnt;}int main(){int n ;while(cin >> n){int k = getPrimeNum(n);for(int i = 0 ; i < k - 1; i++)cout << a[i] << "*";cout << a[k-1] << endl;}return 0;}