#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int x = sqrt(n);
int start = 0, sum, len = 0, temp;//start为连续因子开始位置,sum为连续因子目标值,len为连续因子长度, temp为连续因子暂存的长度
for (int i = 2; i <= x; i ++ )//因为根号n * 根号n >= n所以不能是大于根号n的连续因子,只需要枚举到根号n即可
{
sum = n;
temp = 0;
for (int j = i; sum % j == 0 && sum != 0; j ++ )//若j是sum的因子,且sum还未被除尽
{
sum /= j;
temp ++ ;
}
if (temp > len)//若此长度大于前面循环所推导的次数,则更新当前长度
{
len = temp;
start = i;
}
}
if (len == 0)
{
printf("1\n%d", n);//说明该数无连续因子,即为素数/质数。
}
else
{
printf("%d\n", len);
for (int i = start; i < start + len; i ++ )//从start枚举len的连续因子
{
printf("%d", i);
if (i != start + len - 1) printf("*");
}
}
return 0;
}
04-12
285
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-02
09-16
2781
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)