|
Bestcoder (with Rice!) ) |
Calculate the intersection of a lineTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others) Total submission (s): 8881 Accepted Submission (s): 4006
Problem description plane has n lines, and there is no three-wire common point, ask these straight line can have how many different intersection points. For example, if n=2, the number of possible intersections is 0 (parallel) or 1 (not parallel). Input data consists of multiple test instances, one row per test instance, each containing a positive integer n (n<=20), and n representing the number of lines.
Output each test instance corresponds to a row of outputs, listing all intersecting scenarios from small to large, where each number is the number of possible intersections, separated by a space between the integers in each row. Sample Input23
Sample Output0 10 2 3
Authorlcy SOURCEACM Summer Training Team Practice Competition (ix) Recommendlcy | We have carefully selected several similar problems for you:1176 1087 1003 1159 2084
|
#include <cstdio> #include <cstring>int d[22][220];int main () { memset (d, 0, sizeof D); for (int i = 0; I <=; i++) d[i][0] = 1; for (int n = 2; n <=, n++) for (int i = 1, i < n; i++) for (int j = 0; J <= ((n-i) * (N-i-1))/2; J + +) if (D[n-i][j]) d[n][i * (n-i) + j] = 1; int n; while (~SCANF ("%d", &n)) { int t = (n * (n-1))/2; for (int i = 0; I <= (n * (n-1))/2; i++) if (d[n][i]) i = = t printf ("%d\n", I): printf ("%d", I); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 1466 Straight line intersection case