编程介的小学生 2017-03-29 11:50 采纳率: 20.5%
浏览 896
已采纳

Wu Xing

The Wu Xing, or the Five Movements, Five Phases or Five Steps/Stages, are chiefly an ancient mnemonic device, in many traditional Chinese fields.

The doctrine of five phases describes two cycles, a generating or creation cycle, also known as "mother-son", and an overcoming or destruction cycle, also known as "grandfather-nephew", of interactions between the phases.

Generating:

Wood feeds Fire;
Fire creates Earth (ash);
Earth bears Metal;
Metal carries Water (as in a bucket or tap, or water condenses on metal);
Water nourishes Wood.
Overcoming:

Wood parts Earth (such as roots) (or Trees can prevent soil erosion );
Earth absorbs (or muddies) Water (or Earth dam control the water);
Water quenches Fire;
Fire melts Metal;
Metal chops Wood.
Wu Xing

With the two types of interactions in the above graph, any two nodes are connected by an edge.

Problem

In a graph with N nodes, to ensure that any two nodes are connected by at least one edge, how many types of interactions are required at least? Here a type of interaction should have the following properties:

It can be represented as a set of directed edges in the graph.
For each type of interaction, there should be one and only one edge starting at each node.
For each type of interaction, there should be one and only one edge ending at each node.
The interactions are made up of cycles, i.e. starting from an arbitrary node and following the edges with the same type of interaction, you can always reach the starting node after several steps.
Input

For each test case, there's a line with an integer N (3 <= N < 1,000,000), the number of nodes in the graph.

N = 0 indicates the end of input.
Output

For each test case, output a line with the number of interactions that are required at least.

Sample Input

5
0
Sample Output

2

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-04-07 14:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

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