【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) = ...
随机推荐
- 期望dp+高斯消元+bfs——hdu4418
高斯消元又弄了半天.. 注意只要能建立矩阵,那就必定有解,所以高斯消元里可以直接return 1 #include<bits/stdc++.h> using namespace std; ...
- BZOJ 1084 (SCOI 2005) 最大子矩阵
1084: [SCOI2005]最大子矩阵 Time Limit: 10 Sec Memory Limit: 162 MB Submit: 3560 Solved: 1779 [Submit][Sta ...
- error C2712: Cannot use __try in functions that require object unwinding
转自VC错误:http://www.vcerror.com/?p=52 问题描述: error C2712: Cannot use __try in functions that require ob ...
- 夏令营501-511NOIP训练17——蛇形矩阵
传送门:QAQQAQ 题意:话说小X在孩提时,都会做标准的蛇形矩阵了,发现很好玩.现在的小X很想对其进行改版,变为如下类型的一个无限大蛇形数阵:令S(x)表示以1为左上角,x为右下角的矩形内所有数之和 ...
- Python文件操作回顾
with open("D:/Temp/a.txt", mode='w', encoding='utf-8') as f: f.write('hello') with open(&q ...
- wpf 让正执行的程序暂停几秒钟
public static class DispatcherHelper { [SecurityPermissionAttribute(SecurityAction.Deman ...
- wpf问题集锦
一.今天用vs2013新建wpf程序,项目名称命名为MainWindow,一启动就出现错误:类型“MainWindow.MainWindow”中不存在类型名称"App".博主顿时很 ...
- java_Set接口
/** * Set接口:extends Collection接口 * 不重复性 * 无序 * * java.util.HashSet: * 实现Set接口,不保证set的迭代顺序,无序集合 * 底层是 ...
- Tomcat的优化技巧
(1)参数 minProcessors:最小空闲连接线程数,用于提高系统处理性能,默认值为10. maxProcessors:最大连接线程数,即:并发处理的最大请求数,默认值为75. acceptCo ...
- C#窗体代码相关笔记
获取ComboBox下拉列表的所有选项值 ArrayList al = new ArrayList(); foreach (string item in this.comboBox2.Items) { ...