Advertisement
Guest User

100

a guest
May 16th, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7.  
  8. namespace ConsoleApp2
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int n = int.Parse(Console.ReadLine());
  15.             int[] seq = Console.ReadLine()
  16.                 .Split()
  17.                 .Select(int.Parse)
  18.                 .Distinct()
  19.                 .ToArray();
  20.  
  21.             List<int> nn = new List<int>();
  22.  
  23.             for (int i = 1; i <= n; i++)
  24.             {
  25.                 bool isT = true;
  26.  
  27.                 foreach (int item in seq)
  28.                 {
  29.                     Predicate<int> isDivisible = x => i % x == 0;
  30.  
  31.                     if (!isDivisible(item))
  32.                     {
  33.                         isT = false;
  34.                          break;
  35.                     }
  36.                 }
  37.  
  38.                 if (isT)
  39.                 {
  40.                     nn.Add(i);
  41.                 }
  42.                
  43.             }
  44.             Console.WriteLine(string.Join(' ', nn));
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement