暴力求解。
#include "iostream"
#include "vector"
#include "string"
#include "cstring"
#include "queue"
#include "map"
using namespace std;
int main()
{
int N;
while (cin >> N)
{
int max = 1;
int s = sqrt(N);
int startNum = N;
for (int i = 2; i <= s; i++)
{
if (N%i == 0)
{
int len = 1;
int tempN = N;
tempN /= i;
while (tempN % (++i) == 0)
{
tempN /= i;
++len;
}
if (len > max)
{
max = len;
i = i - len;
startNum = i;
}
else if(len == max && i < startNum)
{
i = i - len;
startNum = i;
}
}
}
cout << max;
for (int i = 0; i < max - 1; i++)
{
cout << startNum++ << '*';
}
cout << startNum;
}
}