1096 Consecutive Factors (20 分)

1096 Consecutive Factors (20 分)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+100;

int main()
{
    ll n;
    scanf("%lld",&n);
    ll ansi=0;
    ll anslen=0;
    for(ll i=2;i*i<=n;i++)
    {
        ll temp=1,j=i;

        while(1)
        {
            temp*=j;
            if(n%temp!=0) break;
            if(j-i+1>anslen)
            {
                ansi=i;
                anslen=j-i+1;
            }
            j++;
        }
    }
    if(anslen==0)
    {
        printf("1\n%lld",n);
    }
    else
    {
        printf("%lld\n",anslen);
        for(ll i=0;i<anslen;i++)
        {
            printf("%lld",ansi+i);
            if(i!=anslen-1) printf("*");
        }
    }
}

上一篇:洛谷 T184172 「EZEC-10」打分


下一篇:Codeforces Round #730 (Div. 2)