Aliendreamer

wormhole

Aug 16th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace wormholeizpit30april
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. int [] wormhole = Console.ReadLine().Split(new[]{' '},StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  15.  
  16. // Console.WriteLine("input done");
  17.  
  18. int count = 0;
  19.  
  20. for(int i=0;i<wormhole.Length;i++)
  21. {
  22. if(wormhole[i]==0)
  23. {
  24. count++;
  25. }
  26. else
  27. {
  28. int temp = wormhole[i];
  29. wormhole[i] = 0;
  30. i = temp;
  31. count++;
  32. }
  33. }
  34.  
  35. Console.WriteLine(count);
  36.  
  37.  
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment