• Codeforces Gym 100342C Problem C. Painting Cottages 转化题意


    Problem C. Painting Cottages
    Time Limit: 2 Sec

    Memory Limit: 256 MB

    题目连接

    http://codeforces.com/gym/100342/attachments

    Description

    The new cottage settlement is organized near the capital of Flatland. The construction company that is building the settlement has decided to paint some cottages pink and others — light blue. However, they cannot decide which cottages must be painted which color. The director of the company claims that the painting is nice if there is at least one pink cottage, at least one light blue cottage, and it is possible to draw a straight line in such a way that pink cottages are at one side of the line, and light blue cottages are at the other side of the line (and no cottage is on the line itself). The main architect objects that there are several possible nice paintings.
    Help them to find out how many different nice paintings are there

    Input

    The first line of the input file contains n — the number of the cottages (1 ≤ n ≤ 300). The following n lines contain the coordinates of the cottages — each line contains two integer numbers xi and yi (−104 ≤ xi , yi ≤ 104 ).

    Output

    Output one integer number — the number of different nice paintings of the cottages.

    Sample Input

    4
    0 0
    1 0
    1 1
    0 1

    Sample Output

    12

    HINT

    题意

         给你n个坐标即点,求出有多少种划分方法

    题解

          q神说题意转化一下,就是这个n个点,能够连多少个不同的线段,

         对于覆盖的线段不算在内,ORZ q神

    代码:

     1 #include <cstdio>
     2 #include <cmath>
     3 #include <cstring>
     4 #include <ctime>
     5 #include <iostream>
     6 #include <algorithm>
     7 #include <set>
     8 #include <vector>
     9 #include <queue>
    10 #include <typeinfo>
    11 #include <map>
    12 #include <stack>
    13 typedef __int64 ll;
    14 #define inf 1000000000000
    15 using namespace std;
    16 inline ll read()
    17 {
    18     ll x=0,f=1;
    19     char ch=getchar();
    20     while(ch<'0'||ch>'9')
    21     {
    22         if(ch=='-')f=-1;
    23         ch=getchar();
    24     }
    25     while(ch>='0'&&ch<='9')
    26     {
    27         x=x*10+ch-'0';
    28         ch=getchar();
    29     }
    30     return x*f;
    31 }
    32 
    33 //**************************************************************************************
    34 
    35 
    36 struct node
    37 {
    38     double x,y;
    39 };
    40 int gcd(int a,int b)
    41 {
    42     if(b==0) return a;
    43     else return gcd(b,a%b);
    44 }
    45 map< pair<int ,int > ,int> H;
    46 node a[333];
    47 int main()
    48 {
    49     freopen("cottages.in","r",stdin);
    50     freopen("cottages.out","w",stdout);
    51     int n=read();
    52     for(int i=0;i<n;i++)
    53         cin>>a[i].x>>a[i].y;
    54     int ans=0;
    55     for(int i=0;i<n;i++)
    56     {
    57         H.clear();
    58         for(int j=i+1;j<n;j++)
    59         {
    60             int aa=a[i].x-a[j].x;
    61             int bb=a[i].y-a[j].y;
    62             int cc=gcd(aa,bb);
    63             if(H[make_pair(aa/cc,bb/cc)]==0)
    64             {
    65                 ans++;
    66                 H[make_pair(aa/cc,bb/cc)]=1;
    67             }
    68         }
    69     }
    70     cout<<ans*2<<endl;
    71 }
  • 相关阅读:
    flash
    三星核S5PV210AH-A0 SAMSUNG
    FATFS(A)
    DDR2是什么意思
    Java中的三大框架分别有什么用
    SD卡
    自动挡汽车档位介绍
    FSMC(STM32)
    陶瓷天线
    'telnet'不是内部或外部命令,怎么办?
  • 原文地址:https://www.cnblogs.com/zxhl/p/4709518.html
Copyright © 2020-2023  润新知