Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OddOrEvenProduct {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- String x = scan.nextLine();
- String[] input = x.split(" ");
- int[] array = new int[input.length];
- int evenProduct = 1;
- int oddProduct = 1;
- for (int i = 0; i < n ; i++) {
- array[i] = Integer.parseInt(input[i]);
- if (i % 2 == 0) {
- evenProduct *= array[i];
- } else {
- oddProduct *= array[i];
- }
- }
- if (evenProduct == oddProduct) {
- System.out.printf("yes %d", evenProduct);
- } else {
- System.out.printf("no %d %d", evenProduct , oddProduct);
- }
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement