1096 Consecutive Factors

1096 Consecutive Factors

 

 

#include <bits/stdc++.h>
# define LL long long
using namespace std;

int main(){
    int N;
    cin>>N;
    int mx=0;
    int idx=0;
    for(int i=2;i<=sqrt(N)+1;i++){
        int tmp=1;
        int j;
        for(j=i;j<=sqrt(N)+1;j++){
            tmp*=j;
            if(N%tmp!=0) break;
        }
        if(j-i>mx){
            mx=j-i;
            idx=i;
        }
    }
    if(mx==0){
        printf("1\n%d", N);
        return 0;
    }
    printf("%d\n",mx);
    for(int i=idx;i<=mx+idx-1;i++){
        if(i>idx) printf("*");
        printf("%d", i);
    }
    return 0;
}

 

上一篇:Lambda表达式


下一篇:快速入门kotlin-Lambda编程,大厂直通车