ZOJ-3328-Wu Xing【7th浙江省赛】
来源:互联网 发布:unity3d 动态生成模型 编辑:程序博客网 时间:2024/06/10 09:20
ZOJ-3328-Wu Xing
Time Limit: 1 Second Memory Limit: 32768 KB
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.
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
题目链接:ZOJ-3328
以下是代码:
#include <vector>#include <map>#include <set>#include <algorithm>#include <iostream>#include <cstdio>#include <cmath>#include <cstdlib>#include <string>#include <cstring>using namespace std;int main(){ int n; while(cin >> n && n) { cout << n / 2 << endl; } return 0;}
- ZOJ-3328-Wu Xing【7th浙江省赛】
- ZOJ 3328 Wu Xing
- ZOJ 3328 Wu Xing
- ZOJ 3328 Wu Xing
- ZOJ 3328 Wu Xing【】
- ZOJ 3328 Wu Xing(五行)
- ZOJ 3328Wu Xing(游戏)
- ZOJ 3328 Wu Xing (五行相生相克找关系)
- ZOJ-3322-Who is Older?【7th浙江省赛】
- ZOJ-3323-Somali Pirates【7th浙江省赛】
- ZOJ-3326-An Awful Problem【7th浙江省赛】【模拟】
- ZOJ-3332-Strange Country II【7th浙江省赛】【dfs】
- ZOJ-3333-Guess the Price【7th浙江省赛】
- ZOJ-3327-Friend Number【7th浙江省赛】【模拟】【数学】
- The 7th Zhejiang Provincial Collegiate Programming Contest - G(Wu Xing)
- The 7th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Wu Xing
- The 7th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Wu Xing
- Wu XING
- Caused by: java.lang.ClassCastException: org.hibernate.type.StringType cannot be cast to org.hiberna
- 前端开发
- java中线程同步
- 系统架构,软件架构,解决方案以及企业架构关系
- GO语言学习:GoEclipse配置
- ZOJ-3328-Wu Xing【7th浙江省赛】
- 【CSS3】结构性伪类选择器—empty
- Django学习随手记(三)
- 制作sig文件
- 关于微信PC扫码支付
- php的memcache和memcached扩展区别
- 关于目前自己iOS项目使用的第三方开源库
- L0,L1,L2正则化浅析
- 韩顺平 javascript教学视频_学习笔记28_dom对象(document对象) 最重要的