Title Description
There N of straight lines on the plane, three lines and no common points, then these straight lines can have a different number of intersection points?
Input Format
A positive integer N
Output Format
An integer that represents the total program
Sample input and output
Description / Tips
N<=25
analysis:
Given n-you $ $ straight lines, which if $ i $ parallel strips, not parallel to the other, then the number of intersections is $ (i * (ni)) $ + (Ni $ $ intersection points of the straight lines). Then we can find $ n $ recursive straight line all the possible scenarios (as $ n $ is small), then record the number of programs on the line.
In fact, it is equivalent to this $ $ n-divided into a number of parallel straight lines of the line group, and then add the number of intersections of a group of a group.
Code:
//It is made by HolseLee on 16th Aug 2019 //Luogu.org P2789 #include<bits/stdc++.h> using namespace std; int n,ans; bool vis[50005]; void dfs(int now,int num) { if( now==0 ) { if( !vis[num] ) ans++; vis[num]=1; return; } for(int i=now; i>=1; --i) dfs(now-i,i*(now-i)+num); } int main () { cin >> n; dfs (n, 0 ); cout << years; return 0 ; }