“玲珑杯”ACM比赛 Round #4 G -- See car
来源:互联网 发布:淘宝店铺招牌是什么 编辑:程序博客网 时间:2024/06/05 09:48
G -- See car
Time Limit:2s Memory Limit:64MByt
DESCRIPTION
You are the god of cars, standing at (a, b) point.There are some cars at point (xi,yi)(xi,yi). If lots of cars and you are in one line, you can only see the car that is nearest to yourself. How many cars can you see?
It is guaranteed that xi>axi>a and yi>byi>b.
INPUT
There are multiple test cases.The first line is a number T (T ≤11 ≤11), which means the number of cases.For each case, first line has three integers a,b,n(−109≤a,b≤109,0≤n≤105)a,b,n(−109≤a,b≤109,0≤n≤105).nextnn lines, each line contains two integer (xi,yi)(−109≤xi,yi≤109)(xi,yi)(−109≤xi,yi≤109), which means the position of car.
OUTPUT
one line --- the number of car that you can see.
SAMPLE INPUT
2
0 0 3
1 1
2 2
3 3
0 0 4
1 1
2 2
2 3
4 6
SAMPLE OUTPUT
1
2
题意:给出自己的所在点,再给出其他车的所在坐标,问你从自己所在位置最多能看到多少辆车,每一个方向只能看到这个方向的第一辆车
#include<cstdio>#include<cstring>#include<set>#include<vector>#include<iostream>#include<algorithm>using namespace std;const int maxn = 1e5 + 10;set<double> s;int main(){int t;scanf("%d",&t);while(t--){int a,b,q;int count = 0;s.clear();scanf("%d%d%d",&a,&b,&q);while(q--){int x,y;scanf("%d%d",&x,&y);double d = (double)(y - b) / (double)(x - a); // 求斜率,用斜率表示方向if(s.find(d) != s.end()) continue;else{s.insert(d);count++;}}printf("%d\n",count);}return 0;}
0 0
- “玲珑杯”ACM比赛 Round #4 G -- See car
- 玲珑杯”ACM比赛 Round #4 G -- See car【Set】
- “玲珑杯”ACM比赛 Round #4 G -- See car【多种容器的运用】
- 玲珑杯1052 - See car——STL集合的应用(“玲珑杯”ACM比赛 Round #4 )
- 玲珑Round #4-G -- See car
- “玲珑杯”ACM比赛 Round #4
- 玲珑杯-【See car】
- “玲珑杯”ACM比赛 Round #4 A -- chess play
- “玲珑杯”ACM比赛 Round #4 E -- array(dp)
- “玲珑杯”ACM比赛 Round #4 E题
- 玲珑杯”ACM比赛 Round #4 E -- array【DP】
- “玲珑杯”ACM比赛 Round #4 B Best couple
- 玲珑杯”ACM比赛 Round #5
- “玲珑杯”ACM比赛 Round #7
- “玲珑杯”ACM比赛 Round #7
- “玲珑杯”ACM比赛 Round #11 " ---1097
- “玲珑杯”ACM比赛 Round #11 D
- “玲珑杯”ACM比赛 Round #11
- 长度为n的数组,取其中k个,要求和为sum,求有多少种取法
- 粒子系统
- 生产者和消费者问题
- 浮点数在内存中的存储方式
- Activity的生命周期和启动模式
- “玲珑杯”ACM比赛 Round #4 G -- See car
- 集合框架
- linux c++ 高并发tcp服务器架构
- matlab_rand生成随机数
- maven 添加第三方依赖
- 基于C#分步式聊天系统的在线视频直播系统设计
- Codeforces Round #378 (Div. 2) C && Codeforces 733C (模拟)详解(两种写法)
- MediaRecorder录制音频 保存到SD卡
- 使用innobackupex、xtrabackup恢复Mysql数据库