【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) = ...
随机推荐
- 阿里云 Aliplayer高级功能介绍(三):多字幕
基本介绍 国际化场景下面,播放器支持多字幕,可以有效解决视频的传播障碍难题,该功能适用于视频内容在全球范围内推广,阿里云的媒体处理服务提供接口可以生成多字幕,现在先看一下具体的效果: WebVTT格式 ...
- STM32硬件错误HardFault_Handler的处理方法
https://blog.csdn.net/electrocrazy/article/details/78173558
- Kmeans算法实现
下面的demo是根据kmeans算法原理实现的demo,使用到的数据是kmeans.txt 1.658985 4.285136 -3.453687 3.424321 4.838138 -1.15153 ...
- day 61 Django基础之django分页
Django基础之django分页 一.Django的内置分页器(paginator) view from django.shortcuts import render,HttpRespons ...
- docker企业级镜像仓库harbor
第一步:安装docker和docker-compose 第二步:下载harbor-offine-installer-v1.5.1.tgz 第三步:上传到/opt,并解压 第四步:修改harbor.cf ...
- 13-7-return的高级使用
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Java SE开发系列-JDK下载安装
JDK下载安装 JDK是Java的开发环境,目前JDK内部也包含了JRE,JRE主要是JAVA程序的运行环境. 点击官方下载地址,按着下图操作即可下载对应系统的不同版本JDK. 进入页面滑到页面底部点 ...
- LeetCode 38.报数(Python3)
题目: 报数序列是一个整数序列,按照其中的整数的顺序进行报数,得到下一个数.其前五项如下: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 被读作 "one 1& ...
- Hadoop 2.x 版本中的依赖 jar
- MapReduce模型简介