Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package probaproba;
- import java.util.Scanner;
- public class OddorEvenProduct {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int n = Integer.parseInt(in.nextLine());
- long odd = 1;
- long even = 1;
- for (int i = 1; i <= n; i++) {
- long nums = in.nextInt();
- if(i%2!=0){
- odd *= nums;
- }
- else{
- even *= nums;
- }
- }
- if(odd == even){
- System.out.printf("yes %d",odd);
- }
- else{
- System.out.printf("no %d %d",odd,even);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment