Advertisement
nassss

Untitled

Apr 1st, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 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.  
  12. int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  13. int oddSum = 1;
  14. int evenSum = 1;
  15.  
  16. for (int i = 1; i < n; i++)
  17. {
  18.  
  19. if (i % 2 == 1)
  20. {
  21. oddSum *= array[i];
  22. }
  23. else
  24. {
  25. evenSum *= array[i -1];
  26. }
  27. }
  28. if (evenSum == oddSum)
  29. {
  30. Console.WriteLine($"yes {evenSum}");
  31. }
  32. else
  33. {
  34. Console.WriteLine($"no {oddSum} {evenSum}");
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement