【codeforces 499C】Crazy Town
【题目链接】:http://codeforces.com/problemset/problem/499/C
【题意】
一个平面,被n条直线分成若干个块;
你在其中的某一块,然后你想要要到的终点在另外一个块;
给出起点坐标(x0,y0),终点坐标(x1,y1);
每次你能从一个块移动到相邻的块;
问你最少需要穿过多少条直线,才能到达终点所在的块;
【题解】
枚举每一条直线;
如果这两个点在这条直线的两边;(即不在一边);
那么肯定最后是需要穿过这条直线的(才能走在一起);
所以答案递增;
代入一般式,看看符号是不是不同即可;
因为有说不在线上,所以不用考虑为0的情况;
【Number Of WA】
0
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0),cin.tie(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
LL x1,y1,x2,y2,a,b,c;
int n,ans = 0;
int main()
{
//Open();
Close();//scanf,puts,printf not use
//init??????
cin >> x1 >> y1;
cin >> x2 >> y2;
cin >> n;
rep1(i,1,n)
{
cin >> a >> b >> c;
LL temp1 = a*x1+b*y1+c;
LL temp2 = a*x2+b*y2+c;
if ( (temp1<0 && temp2>0) || (temp1>0 && temp2<0))
ans++;
}
cout << ans << endl;
return 0;
}
【codeforces 499C】Crazy Town的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【50.00%】【codeforces 602C】The Two Routes
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【77.78%】【codeforces 625C】K-special Tables
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
随机推荐
- react diff 极简版
为什么react这么快呢 ? 因为react用了虚拟DOM: 但是每次虚拟DOM转真实DOM不也是很浪费性能吗 ? nice,所以关键点在Diff算法这里,去对比新旧DOM树,而后通过补丁去更新到真实 ...
- 存储过程被程序和第三方客户端执行很慢,而sql server management studio执行速度正常
来自:http://blog.csdn.net/pgbiao/article/details/22388945 原因分析:由于存储过程是预编译的, 在第一次执行的时候, 会生成执行计划, 以后执行的时 ...
- Vuex听说很难?
Vuex 是什么? Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件状态,并以相应的规则保证状态以一种可预测的方式发生变化. 什么鬼东西 看完这段 ...
- 第三周课堂笔记1thand2thand3th
元组 元组是以逗号隔开的 元组有索引有切片,元组是小括号和中括号的集合, 元组中的东西不可修改(小括号内的东西不可被修改,但是小括号里的列表和字典可以被修改) 2. 由内存地址来分 可变数据类 ...
- vue 计算属性实现过滤关键词
效果 html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <m ...
- js 仿微信投诉—引入vue.js,拆分组件为单个js
效果 页面目录 index.html <!DOCTYPE html > <html> <head> <meta charset="UTF-8&quo ...
- 设置Hadoop+Hbase集群pid文件存储位置
有时候,我们对运行几天或者几个月的hadoop或者hbase集群做停止操作,会发现,停止命令不管用了,为什么呢? 因为基于java开发的程序,想要停止程序,必须通过进程pid来确定,而hadoop和h ...
- sql中on的连接条件与where的区别
left join [表名] on [条件] where [条件] --on表示连接条件 --where表示对结果的过滤条件 两者不尽相同,使用时需注意 例如: select * from tabl ...
- CodeForces - 27E
https://vjudge.net/problem/CodeForces-27E 求因子个数为n的最小的数dfs枚举质因子的幂 #include <iostream> #include ...
- 在python2中的编码
在python2中的编码 #_author:star#date:2019/10/29'''字符编码:ASCII:只能存英文和拉丁字符,gb2312:只能6700中文,1980年gbk1.0:存了200 ...