Codeforces Gym 100342C Problem C. Painting Cottages 转化题意
2015-08-06 23:44
525 查看
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神
代码:
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=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 a,int b) { if(b==0) return a; else return gcd(b,a%b); } map< pair<int ,int > ,int> H; node a[333]; 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; }
相关文章推荐
- [219] Contains Duplicate II
- Failed to initialize storage module: user 的解决方案
- [leedcode 217] Contains Duplicate
- 2015 Multi-University Training Contest 6 -- 1001 Average
- Container With Most Water
- Container With Most Water
- 2015 HUAS Summer Trainning #4~D
- Doing Homework again SDUT 2076
- 2015 Multi-University Training Contest 2
- DELL R710 服务器更换硬盘后,重建RAID1 重装操作系统 无法启动
- POJ 1804 Brainman
- HDOJ1789Doing Homework again(贪心)
- 2015 Multi-University Training Contest 6 hdu 5360 Hiking
- HDU-- 2015 Multi-University Training Contest 6 Cake
- hdu 5360 Hiking(2015 Multi-University Training Contest 6)
- hdu 4750——Count The Pairs
- HDOJ 题目4251The Famous ICPC Team Again(划分树)
- hdu 5353 Average(2015 Multi-University Training Contest 6)
- HDU 5360 Hiking(优先队列)2015 Multi-University Training Contest 6
- POJ 3414 Paid Roads(状态压缩最短路)