Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OddAndEvenProduct {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int N = scanner.nextInt();
- int evenProduct = 1;
- int oddProduct = 1;
- for (int i = 1; i <= N; i++) {
- int num = scanner.nextInt();
- if (i % 2 == 0) {
- evenProduct = evenProduct * num;
- }else {
- oddProduct = oddProduct * num;
- }
- }
- if (evenProduct == oddProduct) {
- System.out.printf("yes %d", evenProduct);
- }else {
- System.out.printf("no %d %d", oddProduct, evenProduct);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement