暴力即可,考虑从2到sqrt(n)作为连续因子里的最小因子。
// 5'10"
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int res = 1;
int num = n;
for(int i = 2; i <= n / i; ++ i)
{
if(n % i != 0) continue;
int now = 1;
int cnt = 0;
for(int j = i; now < n; ++ j, ++ cnt)
{
if(n % (now * j) == 0) now *= j;
else break;
}
if(cnt == res && i < num || cnt > res)
{
res = cnt;
num = i;
}
}
cout << res << endl;
for(int i = 0; i < res; ++ i)
{
cout << num + i;
if(i != res - 1) cout << "*";
else cout << endl;
}
return 0;
}
标签:int,res,因子,num,006,L1
From: https://www.cnblogs.com/Frodnx/p/18335113