Please do in ruby only. Correct and detailed answer will upvoted else downvoted.   To learn as quickly as time permits the most recent news about their number one in a general sense new working framework, BolgenOS people group from Nizhni Tagil chose to foster a plan. As per this plan a local area part, who is quick to become familiar with the news, calls another part, the last mentioned, in his turn, calls some third part, etc; for example an individual with list

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Please do in ruby only. Correct and detailed answer will upvoted else downvoted.

 

To learn as quickly as time permits the most recent news about their number one in a general sense new working framework, BolgenOS people group from Nizhni Tagil chose to foster a plan. As per this plan a local area part, who is quick to become familiar with the news, calls another part, the last mentioned, in his turn, calls some third part, etc; for example an individual with list I got an individual with list fi, to whom he needs to call, on the off chance that he learns the news. With time BolgenOS people group individuals comprehended that their plan doesn't work at times — there were situations when a few individuals didn't become familiar with the news by any stretch of the imagination. Presently they need to enhance the plan: they add into the plan a few directions of type (xi, yi), which imply that individual xi needs to call individual yi too. What is the base measure of guidelines that they need to add all in all, that toward the end everybody learns the news, regardless of who is quick to learn it? 

Input :The initially input line contains number n (2 ≤ n ≤ 105) — measure of BolgenOS people group individuals. The subsequent line contains n space-isolated integer numbers fi (1 ≤ fi ≤ n, i ≠ fi) — record of an individual, to whom calls an individual with list I. 

Output :In the primary line output one number — the base measure of guidelines to add. Then, at that point, output one of the potential variations to add these directions into the plan, one guidance in each line. In the event that the arrangement isn't remarkable, output any

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education