Skip to content

Commit f067ab8

Browse files
committed
feat: update 1096
1 parent 56aba33 commit f067ab8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

PAT/1096/main.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <iostream>
2+
#include <cmath>
3+
using namespace std;
4+
int main() {
5+
int n;
6+
cin >> n;
7+
int maxn = sqrt(n), len = 0, first = 0;
8+
for (int i = 2; i <= maxn; i++) {
9+
int j;
10+
int tmp = 1;
11+
for (j = i; j <= maxn; j++) {
12+
tmp *= j;
13+
if (n % tmp != 0) {
14+
break;
15+
}
16+
}
17+
if (j - i > len) {
18+
len = j - i;
19+
first = i;
20+
}
21+
}
22+
if (first == 0) {
23+
cout << 1 << endl << n;
24+
}
25+
else {
26+
cout << len << endl;
27+
for (int i = 0; i < len; i++) {
28+
cout << first + i;
29+
if (i + 1 != len) {
30+
cout << "*";
31+
}
32+
}
33+
}
34+
return 0;
35+
}

0 commit comments

Comments
 (0)