P2789 直线交点数

时间:2023-03-09 17:20:38
P2789 直线交点数

P2789 直线交点数
分成两种情况,一种是平行直线,一种是*直线,在*直线中可以存在平行直线,但是不能和第一组的直线平行。*直线和平行直线的交点是i*(n-i)。

 #include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<cstring>
#define inf INT_MAX
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar()
//by war
//2017.10.26
using namespace std;
int n;
int tot;
bool f[][]; void in(int &x)
{
int y=;
char c=g();x=;
while(c<''||c>'')
{
if(c=='-')
y=-;
c=g();
}
while(c<=''&&c>='')x=x*+c-'',c=g();
x*=y;
}
void o(int x)
{
if(x<)
{
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
}
int main()
{
in(n);
For(i,,n)
f[i][]=true;
For(i,,n)
For(fr,,i-)
For(j,,(i-)*i/)
if(f[fr][j])
f[i][fr*(i-fr)+j]=true;
For(i,,)
if(f[n][i])
tot++;
o(tot);
return ;
}