Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ListOfPredicates // 66/100 with Memory Limits, but surely fine solution
- {
- class Program
- {
- static void Main(string[] args)
- {
- int range = int.Parse(Console.ReadLine());
- int[] dividers = Console.ReadLine().Split().Select(int.Parse).ToArray();
- Func<int, int[]> funcCreateArray = x =>
- {
- var list = new List<int>();
- for (int i = 1; i <= x; i++)
- {
- list.Add(i);
- }
- return list.ToArray();
- };
- var newArray = funcCreateArray(range);
- foreach (var num in dividers)
- {
- newArray= newArray.Where(x => x % num == 0).ToArray();
- }
- Console.WriteLine(string.Join(" ", newArray));
- }
- }
- }
Add Comment
Please, Sign In to add comment