Advertisement
Schnuk

Untitled

Jun 2nd, 2021
79
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.Collections.Generic;
  3.  
  4. namespace ConsoleApp2
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. var K = 8;
  11. var arr = new int[] { 123, 249, 242, 234 };
  12. for (int i = 0; i < arr.Length; i++)
  13. {
  14. int numberInNewNumberSystem = 0;
  15. while (arr[i] > 0)
  16. {
  17. numberInNewNumberSystem += arr[i] % K;
  18. arr[i] = arr[i] / K;
  19. }
  20. arr[i] = numberInNewNumberSystem;
  21. }
  22.  
  23. var hashSet = new HashSet<int>();
  24. int result = 0;
  25. for (int i = 0; i < arr.Length; i++)
  26. {
  27. if (!hashSet.Contains(arr[i]))
  28. {
  29. hashSet.Add(arr[i]);
  30. result++;
  31. }
  32. }
  33. Console.WriteLine(result);
  34. }
  35. }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement