编程介的小学生 2019-06-11 11:02 采纳率: 20.5%
浏览 276

线性序列的求和累加问题,是怎么使用 C语言的程序设计的思想方法编写的代码设计怎么做

Problem Description
One day dandelion and her friends decides to play outside. As there are so many people , they decide to divide into several parts . Dandelion wants to know how many friends will be together with her. The way they use to divide is : everyone can choose one people to join in her group, Such as if A chooses B to join in her group , then B will leave the group she is in now , and joins in the group that A is in . One can also choose some people who has already in her group. All of dandelion抯 friends are expressed as an integer 2,3... n and dandelion is expressed as 1.The choosing work begins from dandelion then the friend who are signed as 2 ?until the friend who are signed as n .

Input
Each case begins with an integer n, (0<n<=1000000) stands for the number of people.
Then follows n lines , the i+1 line contains an integer p, stands for people who are signed as i chooses the one who are signed as p to join in her group.

Output
The output contains one line for each data set : the number of friends will be together with dandelion at last .

Sample Input
3
3
3
1
3
2
1
2

Sample Output
2
0

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类
    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据