Advertisement
nassss

Untitled

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