基环树:将个点和条边的连通无向图,即在个节点的树上添加一条边恰好包含一个环的图,称为基环树
图的直径:在一个图中,任意两个节点的距离的最大值
个节点构成的所有基环树中,最小的直径是多少?
  1. 时,就是一个最简单的环,此时直径为
  2. 时,可以构造这样的结构:,这样任意两个节点的距离的最大值为
总代码:
#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;
}