Codeforces Gym 100342C Problem C. Painting Cottages 暴力

Problem C. Painting Cottages
Time Limit: 20 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个点,能够连多少个不同的线段就好了,感觉是签到题……

数据范围才300

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
int Num;
char CH[20];
//const int inf=0x7fffffff;   //нчоч╢С
const int inf=0x3f3f3f3f;

inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
    while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
    return x*f;
}
//**************************************************************************************

struct node
{
    double x,y;
};
int gcd(int x,int y)
{
    return y==0?x:gcd(y,x%y);
}
map< pair<int,int> ,int> H;
node a[maxn];
int main()
{
    freopen("cottages.in","r",stdin);
    freopen("cottages.out","w",stdout);
    int n=read();
    for(int i=0;i<n;i++)
        cin>>a[i].x>>a[i].y;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        H.clear();
        for(int j=i+1;j<n;j++)
        {
            int aa=a[i].x-a[j].x;
            int bb=a[i].y-a[j].y;
            int cc=gcd(aa,bb);
            if(H[make_pair(aa/cc,bb/cc)]==0)
            {
                ans++;
                H[make_pair(aa/cc,bb/cc)]=1;
            }
        }
    }
    cout<<ans*2<<endl;
}
时间: 2024-12-16 12:36:51

Codeforces Gym 100342C Problem C. Painting Cottages 暴力的相关文章

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

Problem C. Painting CottagesTime 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 settl

Codeforces Gym 100513I I. Sale in GameStore 暴力

I. Sale in GameStore Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/I Description A well-known Berland online games store has announced a great sale! Buy any game today, and you can download more games for free!

Codeforces Gym 100342D Problem D. Dinner Problem Dp+高精度

Problem D. Dinner ProblemTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description A group of k students from Cooking University living in the campus decided that each day of the semester one of them will p

Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset

Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The travel agency “Four Russians” is offering the new service for their clients. Unlike other agencies that only suggest one-way

Codeforces Gym 100286J Javanese Cryptoanalysis 傻逼暴力

原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-european-regional-contest-neerc-08-en.pdf 此题题意是给你一个单对单密文,让你还原为原文,原文有个性质是,每个单词都是元音和辅音交替组成. 做法是直接5重for,暴力枚举AEIOU分别对应的字母,然后检查,然后输出 详见代码: //#include<iostream>

Codeforces Gym 100610 Problem A. Alien Communication Masterclass 构造

Problem A. Alien Communication Masterclass Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Andrea is a famous science fiction writer, who runs masterclasses for her beloved readers. The most popular one is the

Codeforces Gym 100610 Problem K. Kitchen Robot 状压DP

Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Robots are becoming more and more popular. They are used nowadays not only in manufacturing plants, but also at home. One programmer wit

Codeforces Gym 100610 Problem H. Horrible Truth 瞎搞

Problem H. Horrible Truth Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description In a Famous TV Show “Find Out” there are n characters and only one Horrible Truth. To make the series breathtaking all way long, the sc

Codeforces Gym 100610 Problem E. Explicit Formula 水题

Problem E. Explicit Formula Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Consider 10 Boolean variables x1, x2, x3, x4, x5, x6, x7, x8, x9, and x10. Consider all pairs and triplets of distinct variables amon