觉得pat的题意理解真的很重要,经常没有明白题目的意思,注意结合例子分析题目。
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long LL;
int main()
{
LL n;
scanf("%lld", &n);
LL sqr = (LL)sqrt(1.0*n);
LL lenm=0;
LL begin;
for (LL i = 2; i <= sqr; i++)
{
LL j = i,temp=1;
while(1)
{
temp *= j;
if (n%temp != 0) break;
if (j - i + 1 > lenm)
{
begin = i;
lenm = j - i + 1;
}
j++;
}
}
if (lenm == 0)
{
printf("1\n");
printf("%lld", n);
}
else
{
printf("%lld\n", lenm);
for (LL i = begin; i < begin+lenm; i++)
{
printf("%lld",i);
if (i != begin+lenm - 1) printf("*");
}
}
return 0;
}