Advertisement
gamezovladislav

Untitled

Oct 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     static Scanner in = new Scanner(System.in);
  6.  
  7.     public static void main(String[] args) {
  8.         int n = in.nextInt();
  9.         int[] a = new int[n];
  10.         for (int i = 0; i < n; i++) {
  11.             a[i] = in.nextInt();
  12.         }
  13.         boolean f = false;
  14.         for (int i = 0; i + 2 < n; i++) {
  15.             if (a[i + 1] % a[i] == 0) {
  16.                 int d = a[i + 1] / a[i];
  17.                 if (a[i + 2] == a[i + 1] * d) {
  18.                     f = true;
  19.                     System.out.print(a[i] + " " + a[i + 1] + " " + a[i + 2] + " ");
  20.                     i += 2;
  21.                     while (i + 1 < n && a[i + 1] == a[i] * d) {
  22.                         System.out.print(a[i + 1] + " ");
  23.                         i++;
  24.                     }
  25.                     System.out.println();
  26.                 }
  27.             }
  28.         }
  29.         if (!f) {
  30.             System.out.println("Not found");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement