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神

代码:

 #include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <typeinfo>
#include <map>
#include <stack>
typedef __int64 ll;
#define inf 1000000000000
using namespace std;
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
} //************************************************************************************** struct node
{
double x,y;
};
int gcd(int a,int b)
{
if(b==) return a;
else return gcd(b,a%b);
}
map< pair<int ,int > ,int> H;
node a[];
int main()
{
freopen("cottages.in","r",stdin);
freopen("cottages.out","w",stdout);
int n=read();
for(int i=;i<n;i++)
cin>>a[i].x>>a[i].y;
int ans=;
for(int i=;i<n;i++)
{
H.clear();
for(int j=i+;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)]==)
{
ans++;
H[make_pair(aa/cc,bb/cc)]=;
}
}
}
cout<<ans*<<endl;
}

Codeforces Gym 100342C Problem C. Painting Cottages 转化题意的更多相关文章

  1. Codeforces Gym 100342C Problem C. Painting Cottages 暴力

    Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1 ...

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

    Problem D. Dinner ProblemTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1003 ...

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

    Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  4. Codeforces Gym 100500F Problem F. Door Lock 二分

    Problem F. Door LockTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/at ...

  5. Codeforces Gym 100610 Problem A. Alien Communication Masterclass 构造

    Problem A. Alien Communication Masterclass Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codefo ...

  6. Codeforces Gym 100610 Problem K. Kitchen Robot 状压DP

    Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10061 ...

  7. Codeforces Gym 100610 Problem H. Horrible Truth 瞎搞

    Problem H. Horrible Truth Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1006 ...

  8. Codeforces Gym 100610 Problem E. Explicit Formula 水题

    Problem E. Explicit Formula Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...

  9. Codeforces Gym 100002 Problem F "Folding" 区间DP

    Problem F "Folding" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/ ...

随机推荐

  1. asp.net缓存(转)

    转自:http://www.cnblogs.com/knowledgesea/archive/2012/06/20/2536603.html 一.缓存概念,缓存的好处.类型.            缓 ...

  2. 优化sql语句

    关于数据库sql语句的优化? 这个链接可以看 涉及数据库的操作基本都是变得很慢了, 所以通常说数据库是程序的瓶颈 测试/优化数据库/sql的方法: 把order排序.where条件等一个一个去除法来做 ...

  3. 10 steps to becoming the developer everyone wants

    You thought it was all about programming skills. But you were wrong! Great code is fine, yet command ...

  4. Mac SVN <CornerStone>的安装和配置

    cornerstone需要注意的地方 cornerstone文件夹的删除必须在 cornerstone软件里面删, 否则commit就会显示 up of date, 同步不了 http://www.t ...

  5. 关于mac安装rails报错clang: error: unknown argument

    文章都是从我的个人博客上转载过来的,大家可以点击我的个人博客. www.iwangzheng.com mac上安装rails的时候报错, 安装rails的在终端执行了一句命令: $sudo gem i ...

  6. Linux文件权限管理(持续更新)

    文章是从我的个人博客上粘贴过来的, 大家也可以访问我的主页 www.iwangzheng.com 以root身份登录linux以后, ls -al 可以看到 -rw-rw-r--  1 wangzhe ...

  7. 跟着百度学PHP[1]-if条件嵌套

    权当自己的学习笔记.望大牛们切勿参考.如若发现错误,万望指出!  慕课任务 假设在发工资的时候,不仅判定性别,还要判定男性是否有房,没有房,可以发放住房补贴,对于女性,判定是否怀孕,怀孕还有怀孕补贴. ...

  8. Coursera台大机器学习课程笔记9 -- Logistic Regression

    如果只想得到某种概率,而不是简单的分类,那么该如何做呢?在误差衡量问题上,如何选取误差函数这段很有意思. 接下来是如何最小化Ein,由于Ein是可凸优化的,所以采用的是梯度下降法:只要达到谷底,就找到 ...

  9. PHP 遍历目录

    $dir = $_SERVER['DOCUMENT_ROOT'].'/test'; //var_dump($dir);exit; function my_scandir($dir) { $files ...

  10. macbook air 安装win7双系统

    转自: http://jingyan.baidu.com/article/6d704a13f99f1a28da51ca49.html 1)遇到“No bootable device-insert bo ...