HDU 1466 Straight line intersection case

Source: Internet
Author: User

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 Input
23

Sample Output
0 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.