-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL1-006 连续因子.cpp
More file actions
45 lines (45 loc) · 1005 Bytes
/
L1-006 连续因子.cpp
File metadata and controls
45 lines (45 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
int ss[100];
int main()
{
unsigned long long n;
int bj = 0;
scanf("%llu", &n);
int gen = sqrt(n);
int ans = 0;
for(int i = 2; i <= gen*2; i++) {
if(n%i == 0) {
int nt = 0;
unsigned long long tt = n;
for(int j = i; j <= gen*2 && tt%j == 0; j++) {
tt = tt/j;
nt++;
}
if(nt > ans) {
ans = nt;
memset(ss, 0, sizeof(ss));
bj = 0;
for(int j = i; j < i+nt; j++) {
ss[bj++] = j;
}
}
}
}
if(bj == 0) {
printf("1\n%llu\n", n);
} else {
printf("%d\n", ans);
printf("%d", ss[0]);
for(int i = 1; i < bj; i++) {
printf("*%d", ss[i]);
}
printf("\n");
}
return 0;
}