基环树:将
个点和
条边的连通无向图,即在
个节点的树上添加一条边恰好包含一个环的图,称为基环树
图的直径:在一个图中,任意两个节点的距离的最大值
-
当
时,就是一个最简单的环,此时直径为
-
当
时,可以构造这样的结构:
,这样任意两个节点的距离的最大值为
总代码:
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define HelloWorld IOS;
signed main(){
HelloWorld;
int n; cin >> n;
if(n == 3) cout << 1 << endl;
else cout << 2 << endl;
return 0;
}



京公网安备 11010502036488号