SHARE
TWEET

Untitled

a guest May 21st, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2. import java.util.Scanner;
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner input = new Scanner(System.in);
  7.         int N = input.nextInt();
  8.  
  9.         int oddProduct = 1;
  10.         int evenProduct = 1;
  11.         int [] rowData = new int[N];
  12.  
  13.         for (int i = 0; i <= rowData.length-1; i++) {
  14.             rowData [i] = input.nextInt();
  15.         }
  16.  
  17.         for (int i = 0; i < rowData.length; i+=2) {
  18.             oddProduct *= rowData[i];
  19.         }
  20.         for (int i = 1; i < rowData.length; i+=2) {
  21.             evenProduct *= rowData[i];
  22.         }
  23.         if (oddProduct==evenProduct){
  24.             System.out.println("yes "+ oddProduct);
  25.         }
  26.         else{
  27.             System.out.println("no "+oddProduct+" "+evenProduct);
  28.  
  29.         }
  30.         }
  31.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top