Wu Xing

描述

Introduction

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.
在这里插入图片描述
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.
输入

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.

输出

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

样例输入

5
0

样例输出

2
分析:挑战智商的题!
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin>>n&&n)
{
cout<<n/2<<endl;
}
return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
public static String wuxing(String gzYear, String gzMonth, String gzDay, String gzTime) { // 天干年 String gYear = gzYear.substring(0, 1); if ("甲".equals(gYear) || "乙".equals(gYear)) { gYear = "木"; } if ("丙".equals(gYear) || "丁".equals(gYear)) { gYear = "火"; } if ("戊".equals(gYear) || "己".equals(gYear)) { gYear = "土"; } if ("庚".equals(gYear) || "辛".equals(gYear)) { gYear = "金"; } if ("壬".equals(gYear) || "癸".equals(gYear)) { gYear = "水"; } // 天干月 String gMonth = gzMonth.substring(0, 1); if ("甲".equals(gMonth) || "乙".equals(gMonth)) { gMonth = "木"; } if ("丙".equals(gMonth) || "丁".equals(gMonth)) { gMonth = "火"; } if ("戊".equals(gMonth) || "己".equals(gMonth)) { gMonth = "土"; } if ("庚".equals(gMonth) || "辛".equals(gMonth)) { gMonth = "金"; } if ("壬".equals(gMonth) || "癸".equals(gMonth)) { gMonth = "水"; } // 天干日 String gDay = gzDay.substring(0, 1); if ("甲".equals(gDay) || "乙".equals(gDay)) { gDay = "木"; } if ("丙".equals(gDay) || "丁".equals(gDay)) { gDay = "火"; } if ("戊".equals(gDay) || "己".equals(gDay)) { gDay = "土"; } if ("庚".equals(gDay) || "辛".equals(gDay)) { gDay = "金"; } if ("壬".equals(gDay) || "癸".equals(gDay)) { gDay = "水"; } // 天干时 String gTime = gzTime.substring(0, 1); if ("甲".equals(gTime) || "乙".equals(gTime)) { gTime = "木"; } if ("丙".equals(gTime) || "丁".equals(gTime)) { gTime = "火"; } if ("戊".equals(gTime) || "己".equals(gTime)) { gTime = "土"; } if ("庚".equals(gTime) || "辛".equals(gTime)) { gTime = "金"; } if ("壬".equals(gTime) || "癸".equals(gTime)) { gTime = "水"; }
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值