Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <assert.h>
- #define MAXN 1000
- int main() {
- int N, i, j;
- int max, maxSeq,lSeq;
- max = 1;
- lSeq = 1;
- assert(1 == scanf("%d", &N));
- int* V = new int[N];
- for (i = 0; i < N - 1; i++) {
- assert(1 == scanf("%d", &V[i]));
- if (V[i]%maxSeq == 0 || maxSeq%V[i] == 0) {
- lSeq++;
- if (maxSeq < V[i]) maxSeq = V[i];
- }
- else {
- if (max < lSeq) max = lSeq;
- lSeq = 1;
- maxSeq = V[i];
- for (j = i - 1; j >= 0; j--) {
- if (V[i] % V[j] == 0 || V[j] % V[i] == 0) {
- lSeq++;
- if (maxSeq < V[j]) maxSeq = V[j];
- }
- else break;
- }
- }
- }
- printf("%d", max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment