Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- static Scanner in = new Scanner(System.in);
- public static void main(String[] args) {
- int n = in.nextInt();
- int[] a = new int[n];
- for (int i = 0; i < n; i++) {
- a[i] = in.nextInt();
- }
- boolean f = false;
- for (int i = 0; i + 2 < n; i++) {
- if (a[i + 1] % a[i] == 0) {
- int d = a[i + 1] / a[i];
- if (a[i + 2] == a[i + 1] * d) {
- f = true;
- System.out.print(a[i] + " " + a[i + 1] + " " + a[i + 2] + " ");
- i += 2;
- while (i + 1 < n && a[i + 1] == a[i] * d) {
- System.out.print(a[i + 1] + " ");
- i++;
- }
- System.out.println();
- }
- }
- }
- if (!f) {
- System.out.println("Not found");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement