Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace wormholeizpit30april
- {
- class Program
- {
- static void Main(string[] args)
- {
- int [] wormhole = Console.ReadLine().Split(new[]{' '},StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- // Console.WriteLine("input done");
- int count = 0;
- for(int i=0;i<wormhole.Length;i++)
- {
- if(wormhole[i]==0)
- {
- count++;
- }
- else
- {
- int temp = wormhole[i];
- wormhole[i] = 0;
- i = temp;
- count++;
- }
- }
- Console.WriteLine(count);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment