Guest User

Untitled

a guest
Sep 21st, 2019
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. package probaproba;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class OddorEvenProduct {
  6. public static void main(String[] args) {
  7. Scanner in = new Scanner(System.in);
  8.  
  9. int n = Integer.parseInt(in.nextLine());
  10.  
  11. long odd = 1;
  12. long even = 1;
  13. for (int i = 1; i <= n; i++) {
  14. long nums = in.nextInt();
  15. if(i%2!=0){
  16. odd *= nums;
  17. }
  18. else{
  19. even *= nums;
  20. }
  21.  
  22. }
  23. if(odd == even){
  24. System.out.printf("yes %d",odd);
  25. }
  26. else{
  27. System.out.printf("no %d %d",odd,even);
  28. }
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment