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神
代码:
#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 转化题意的更多相关文章
- Codeforces Gym 100342C Problem C. Painting Cottages 暴力
Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1 ...
- Codeforces Gym 100342D Problem D. Dinner Problem Dp+高精度
Problem D. Dinner ProblemTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1003 ...
- Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset
Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
- Codeforces Gym 100500F Problem F. Door Lock 二分
Problem F. Door LockTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/at ...
- Codeforces Gym 100610 Problem A. Alien Communication Masterclass 构造
Problem A. Alien Communication Masterclass Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codefo ...
- 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 ...
- Codeforces Gym 100610 Problem H. Horrible Truth 瞎搞
Problem H. Horrible Truth Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1006 ...
- Codeforces Gym 100610 Problem E. Explicit Formula 水题
Problem E. Explicit Formula Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
- Codeforces Gym 100002 Problem F "Folding" 区间DP
Problem F "Folding" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/ ...
随机推荐
- 百度或者Google---SEO优化(转载)
google 和百度的技术差别: 1.百度还认不清哪个是原创的 2.google蜘蛛不够百度快 4.google排名结果随时变化 流量.权重.权威.内容.用户体验.用户关注度等等细节的排名,已表 达了 ...
- Windows 下配置使用MemCached(转载)
工具: memcached-1.2.6-win32-bin.zip MemCached服务端程序(for win) Memcached Manager win下的Mem ...
- 解决Jquery对input file控件的onchange事件只生效一次的问题
如题,解决办法的代码如下: 1. $('#fileId').live('change',function(){ //逻辑添加.... }); 2. $('#fileId').change(functi ...
- cad2013
## ribbon界面? ribbon界面是一种设计ui, 可以认为是传统的 菜单和工具栏 组合. 是 用于 实时显示 + 面向结果的 设计ui 但并不是所有的程序都适合. ribbon 并不是 ...
- [转载]AngularJS and scope.$apply
http://jimhoskins.com/2012/12/17/angularjs-and-apply.html http://www.cnblogs.com/zhrj000/p/3383898.h ...
- sql重复记录查询
1.查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断 select * from people where peopleId in (select peopleId fro ...
- 如何在linux中用命令产生一个范围内的随机数?
在shell中有一个环境变量RANDOM,它的范围是0--32767 如果我们想要产生0-25范围内的数,如何做呢?如下: $RANDOM%26 用这个环境变量对26取模,就可以得到最小是0,最大是2 ...
- WCDMA是什么意思?CDMA是什么意思?GSM是什么意思
有些朋友在购买3G智能手机的时候会遇到这样的困惑,为什么相同的手机会有不同手机网络制式之分呢?有的支持WCDMA/GSM,有的支持CDMA/GSM,到底自己应该选购哪一种手机好呢?WCDMA是什么意思 ...
- Encode and Decode Strings
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...
- Java for LeetCode 150 Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, ...