原题传送门
从某一点出发,一笔画最多几条边
就是从一个完全图最少删去几条边使之能一笔画
发现如果点数是奇数,那么每个点的度数都是偶数,直接一笔画
如果点数是偶数,每个点的度数都是奇数,根据小学奥数,度数为奇数的点有0/2个时候,可以一笔画,又删去一条边可以减少两个度数为奇数的点,所以删去
n
/
2
−
1
n/2-1
n/2−1条边
Code:
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int read(){
int s = 0, w = 1;
char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') w = -1;
for (; isdigit(c); c = getchar()) s = (s << 1) + (s << 3) + (c ^ 48);
return s * w;
}
int main(){
int T = read();
while (T--){
LL n = read();
if (n & 1) printf("%lld\n", n * (n - 1) >> 1);
else printf("%lld\n", n * (n - 1) / 2 - (n / 2 - 1));
}
return 0;
}