Guest User

Untitled

a guest
Nov 6th, 2017
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <assert.h>
  3.  
  4. #define MAXN 1000
  5.  
  6. int main() {
  7.  
  8. int N, i, j;
  9. int max, maxSeq,lSeq;
  10.  
  11. max = 1;
  12. lSeq = 1;
  13.  
  14. assert(1 == scanf("%d", &N));
  15.  
  16. int* V = new int[N];
  17.  
  18. for (i = 0; i < N - 1; i++) {
  19. assert(1 == scanf("%d", &V[i]));
  20. if (V[i]%maxSeq == 0 || maxSeq%V[i] == 0) {
  21. lSeq++;
  22. if (maxSeq < V[i]) maxSeq = V[i];
  23. }
  24. else {
  25. if (max < lSeq) max = lSeq;
  26. lSeq = 1;
  27. maxSeq = V[i];
  28. for (j = i - 1; j >= 0; j--) {
  29. if (V[i] % V[j] == 0 || V[j] % V[i] == 0) {
  30. lSeq++;
  31. if (maxSeq < V[j]) maxSeq = V[j];
  32. }
  33. else break;
  34. }
  35. }
  36. }
  37.  
  38. printf("%d", max);
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment