fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. class S
  5. {
  6. static void Main()
  7. {
  8. int K = int.Parse(Console.ReadLine());
  9. Console.ReadLine();
  10. var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
  11. var toTest = new List<int>();
  12. foreach(var v in inputs){
  13. toTest.Add(v);
  14. for(var i = toTest.Count-1; i >= 0; i--){
  15. toTest.Add(v+toTest[i]);
  16. }
  17. }
  18. Console.WriteLine(toTest.Any(t => K % t == 0)?"Yes":"No");
  19. }
  20. }
Success #stdin #stdout 0.02s 17404KB
stdin
19
3
5 7 11
stdout
No