Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7. int n = int.Parse(Console.ReadLine());
  8.  
  9. int[] array = new int[n];
  10.  
  11. for (int i = 0; i<n;i++) {
  12. array[i]=int.Parse(Console.ReadLine());
  13. }
  14.  
  15. for (int i = 1; i < n; i++) {
  16. while (array[i]%array[i-1]!=0) {
  17. if (array[i]>array[i-1]) {
  18. array[i] -= array[i-1];
  19. }
  20. else {
  21. array[i-1] -= array[i];
  22. }
  23. }
  24.  
  25. if (array[i-1]<array[i]) {
  26. array[i] = array[i-1];
  27. }
  28. }
  29.  
  30. Console.WriteLine(array[n-1]);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement