B. Han Solo and Lazer Gun
来源:互联网 发布:mac影音播放器 编辑:程序博客网 时间:2024/05/21 06:46
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0, y0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x0, y0).
Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers.
The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location.
The first line contains three integers n, x0 и y0 (1 ≤ n ≤ 1000, - 104 ≤ x0, y0 ≤ 104) — the number of stormtroopers on the battle field and the coordinates of your gun.
Next n lines contain two integers each xi, yi ( - 104 ≤ xi, yi ≤ 104) — the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point.
Print a single integer — the minimum number of shots Han Solo needs to destroy all the stormtroopers.
4 0 01 12 22 0-1 -1
2
2 1 21 11 0
1
Explanation to the first and second samples from the statement, respectively:
解题说明:此题是一道几何模拟题,判断点是否在一条直线上即可。
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#include<cmath>#include<cstdlib>using namespace std;int main(){ int x,y; int s[1000][2]; int n; int i,j,c=0; int k[1000]; scanf("%d%d%d",&n,&x,&y); for(i=0; i<n; i++,c++) { scanf("%d%d",&s[i][0],&s[i][1]); for(j=0; j<i; j++) { if((s[i][0]-x)*(s[j][1]-y)==(s[i][1]-y)*(s[j][0]-x)) { c--; break; } } } printf("%d\n",c); return 0;}
- B. Han Solo and Lazer Gun
- B. Han Solo and Lazer Gun
- B. Han Solo and Lazer Gun
- Han Solo and Lazer Gun
- CodeForces 514B Han Solo and Lazer Gun
- CodeForces 518B - Han Solo and Lazer Gun
- CodeForces - 514B Han Solo and Lazer Gun
- Codeforces 514B Han Solo and Lazer Gun【思维】
- Codeforces Round #291 (Div. 2) -- B. Han Solo and Lazer Gun (计算几何~暴力)
- Han Solo and Lazer Gun (Codeforces Round #291 (Div. 2)B)
- Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun
- Codeforces 514 B . Han Solo and Lazer Gun 精度 除0
- Codeforces Round #291 (Div. 2)---B. Han Solo and Lazer Gun
- Codeforces Round #291 (Div. 2) Han Solo and Lazer Gun
- Codeforces Round #291 (Div. 2) Han Solo and Lazer Gun
- Gun
- Bestcoder #47 B Senior's Gun
- gun and rose 的我很喜欢的一首歌
- 字符串删减函数
- shell 中的替换文本命令
- Thinkphp3.1.3学习——2、配置文件(单入口时)
- snmp网络协议总结一二
- css 选择器
- B. Han Solo and Lazer Gun
- 为什么这么任性!
- StreamingMedia——模糊问题总结
- iOS面试题
- android日期工具类DateHelper
- 使用nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器笔记(十)
- 虚拟继承的类对象的空间大小
- 计算机底层知识拾遗(八)理解物理内存管理
- Android触摸事件分发机制