Advertisement
Guest User

Untitled

a guest
May 6th, 2021
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = scanner.nextInt();
  8. int oddProductValue =1, evanProductValue = 1;
  9. int num;
  10.  
  11. for (int i = 1; i <= n; i++) {
  12. num = Integer.parseInt(scanner.next());
  13. if(i%2 != 0){
  14. oddProductValue *= num;
  15. }
  16. else {
  17. evanProductValue *= num;
  18. }
  19.  
  20. }
  21.  
  22. if(oddProductValue == evanProductValue){
  23. System.out.printf("yes %d", oddProductValue);
  24. }
  25. else {
  26. System.out.printf("no %d %d", oddProductValue, evanProductValue);
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement