Advertisement
nassss

Untitled

Apr 1st, 2020
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace OddAndEvenProducts
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int n = int.Parse(Console.ReadLine());
  11. int oddProduct = 1;
  12. int evenProduct = 1;
  13. int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14.  
  15. for (int i = 0; i < n; i++)
  16. {
  17. if (i % 2 == 0)
  18. {
  19. oddProduct *= numbers[i];
  20. }
  21. else
  22. {
  23. evenProduct *= numbers[i];
  24. }
  25. }
  26. if (evenProduct == oddProduct)
  27. {
  28. Console.WriteLine($"yes {oddProduct}");
  29. }
  30. else
  31. {
  32. Console.WriteLine($"no {evenProduct} {oddProduct}");
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement