You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
//https://www.luogu.com.cn/blog/user34320/solution-p2789
using namespace std;
const int N = 310;
bool visit[N];
/**
对p条直线分情况讨论平行线的条数已知在有r条平行线时有p-r条线与他们相交于p*p-r个交点
再加上对于这p-r个交点的相交组合即可
*/
/**
* 功能讨论处理n条线的交点数情况有哪些
* @param p n条线
* @param sum 已经确定的交点数量
*/
void g(int p, int sum) {
//标记k个结点数量是存在的
visit[sum] = true;
//递归出口如果0条直线就返回吧
if (p == 0) return;
//n条直线中存在的平行线条数需要逐个遍历一遍
for (int r = p; r >= 1; r--)
g(p - r, r * (p - r) + sum);
}
int main() {
//输入
int n, ans;
cin >> n;
//从n条直线交点数量为0全部平行开始讨论
g(n, 0);
//统计结果
for (int i = 0; i < N; i++) ans += visit[i];
//输出结果
cout << ans;
return 0;
}