Skip to content

Commit

Permalink
🔙 revert: revert a commit
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchuo committed Mar 19, 2019
1 parent 8f2b036 commit ad73d8f
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions AdvancedLevel_C++/1096. Consecutive Factors (20).cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int max = sqrt(n);
for(int len = 12; len >= 1; len--) {
for(int start = 2; start <= max; start++) {
long long int ans = 1;
for(int i = start; i - start <= len - 1; i++)
ans *= i;
if(n % ans == 0) {
printf("%d\n%d", len, start);
for(int i = start + 1; i - start <= len - 1; i++)
printf("*%d", i);
return 0;
}
long int num, temp;
int main(){
cin >> num;
int first = 0, len = 0, maxn = sqrt(num) + 1;
for (int i = 2; i <= maxn; i++) {
int j;
temp = 1;
for (j = i; j <= maxn; j++) {
temp *= j;
if (num % temp != 0) break;
}
if (j - i > len) {
len = j - i;
first = i;
}
}
if (first == 0) {
cout << 1 << endl << num;
} else {
cout << len << endl;
for (int i = 0; i < len; i++) {
cout << first + i;
if (i != len - 1) cout << '*';
}
}
printf("1\n%d", n);
return 0;
}

0 comments on commit ad73d8f

Please sign in to comment.