题干:

As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only if they help his son complete a programming task. The task goes like that.

Let's consider a set of functions of the following form:

Let's define a sum of n functions y1(x), ..., yn(x) of the given type as functions(x) = y1(x) + ... + yn(x) for any x. It's easy to show that in this case the graph s(x)is a polyline. You are given n functions of the given type, your task is to find the number of angles that do not equal 180 degrees, in the graph s(x), that is the sum of the given functions.

Valeric and Valerko really want to watch the next Euro Championship game, so they asked you to help them.

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of functions. Each of the following n lines contains two space-separated integer numbers ki, bi ( - 109 ≤ ki, bi ≤ 109) that determine the i-th function.

Output

Print a single number — the number of angles that do not equal 180 degrees in the graph of the polyline that equals the sum of the given functions.

Examples

Input

1
1 0

Output

1

Input

3
1 0
0 2
-1 1

Output

2

Input

3
-2 -4
1 7
-5 1

Output

3

题目大意:

定义一个y()函数,然后定义一个s(x)函数,问我们s(x)函数上有多少个不是180°的倾角。

解题报告:

我们假象y(x)不是那样定义的,它就是简单的一次函数,那么n个一次函数相加肯定是一次函数,都是180°的倾角(直的),那么问题就出现在y(x)<0时,y(x)=0,也就是它本身应该加上一个小于0的数结果加上0了,所以就会有弯曲。也就是记录与x轴有多少不同的交点。

这题要是直接用set存,然后需要开long double 记录斜率,并且选择合适的编译器,才可以ac。。。不然就卡精度

更好的方法是直接以最简分数的方式存啊。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<set>
#define ll long long
#define mp make_pair
using namespace std;
struct Node {ll b,k;
} node[100000 + 5];
set<pair<ll,ll> > st;
int main ()
{ll n,k,b;cin>>n;for(int i = 1; i<=n; i++) {scanf("%lld%lld",&k,&b);if(k == 0) continue;if(k<0&&b<0) k=-k,b=-b;if(b == 0) {st.insert(mp(0,0));continue;}if(k<0&&b>0) k=-k,b=-b;st.insert(mp(k/__gcd(abs(k),abs(b)),b/__gcd(abs(k),abs(b)))); }cout << st.size() << endl;return 0 ;
}

【CodeForces - 195D】Analyzing Polyline (思维,卡精度的处理方式)相关推荐

  1. 51nod 1172 Partial Sums V2 卡精度的任意模数FFT

    卡精度的任意模数fft模板题-- 这道题随便写个表就能看出规律来(或者说考虑一下实际意义),反正拿到这题之后,很快就会发现他是任意模数fft模板题. 然后我就去网上抄了一下板子-- 我打的是最土的任意 ...

  2. 【HDU - 2570】迷瘴 (贪心,水题,排序,卡精度有坑)

    题干: 通过悬崖的yifenfei,又面临着幽谷的考验--  幽谷周围瘴气弥漫,静的可怕,隐约可见地上堆满了骷髅.由于此处长年不见天日,导致空气中布满了毒素,一旦吸入体内,便会全身溃烂而死.  幸好y ...

  3. pytorch单机多卡的正确打开方式 以及可能会遇到的问题和相应的解决方法

    pytorch 单机多卡的正确打开方式 pytorch 使用单机多卡,大体上有两种方式 简单方便的 torch.nn.DataParallel(很 low,但是真的很简单很友好) 使用 torch.d ...

  4. [分布式训练] 单机多卡的正确打开方式:Horovod

    [分布式训练] 单机多卡的正确打开方式:Horovod 转自:https://fyubang.com/2019/07/26/distributed-training4/ 讲完了单机多卡的分布式训练的理 ...

  5. [分布式训练] 单机多卡的正确打开方式:PyTorch

    [分布式训练] 单机多卡的正确打开方式:PyTorch 转自:https://fyubang.com/2019/07/23/distributed-training3/ PyTorch的数据并行相对于 ...

  6. [分布式训练] 单机多卡的正确打开方式:理论基础

    [分布式训练] 单机多卡的正确打开方式:理论基础 转自:https://fyubang.com/2019/07/08/distributed-training/ 瓦砾由于最近bert-large用的比 ...

  7. 关于销售订单挑库发放卡接口以及发运处理卡接口的处理方式

    1.关于销售订单挑库发放卡接口的处理方式: 在处理异常过程中,有时会碰到销售挑库后物料已有保留,但是交易记录就一直卡接口,到待定事务处理处提交也不成功,也没任何错误提示. 对于出现上面的情况,只能将接 ...

  8. 小米手环/华为手环复制无法识别的加密校园卡(可刷门禁,只需一张卡,最简单方式)

    小米手环复制校园卡(最简单方式),解决小米手环不能复制门禁卡. 注意,这里的校园卡是加密卡,一般不容易破解,这里只是读取并写入0扇区的第一行数据,只能够身份识别充当门禁卡,不能进行消费等其他行为.(写 ...

  9. 【CodeForces - 264A】Escape from Stones (模拟,卡精度的处理)

    题干: Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a m ...

最新文章

  1. 从0到1,苏宁API网关的演进之路
  2. Pandas 中的 concat 函数
  3. OVS端口镜像(十四)
  4. 今天的但我发现了幸福的超级玛丽,白萝卜的种子
  5. zookeeper 环境搭建之(Windows上的简单部署)
  6. Idea搭建SpringCloud(四)------利用Feign实现负载均衡
  7. Windows 下Maven安装配置(本地仓库配置)
  8. windows电脑记事本怎么自由排序?
  9. 微信公众号前端支付实现
  10. Java程序员的MacBookPro(14寸M1)配置备忘录
  11. 媒体选择与发布实践总结
  12. 7-11 秋天的第一杯奶茶 (20 分)
  13. 计算机网络 自顶向下方法.原书第6版 - 网络层次、应用、发展
  14. Matlab plot 光滑曲线
  15. 行为识别(CVPR2020南京大学腾讯) ~ TEA论文笔记 ~《TEA: Temporal Excitation and Aggregation for Action Recognition》
  16. LLJ-F(S)系列漏电继电器
  17. 【狂神说】Docker 学习笔记【基础篇】
  18. python报错ValueError: Found input variables with inconsistent numbers of samples: [x,y]
  19. 前端框架React Js入门教程【转】
  20. 一季度全国主要城市交通分析报告 高德发布

热门文章

  1. [Leetcode][第39题][JAVA][组合总和][回溯][dfs][剪枝]
  2. linux 端口tnpl,Linux和Windows端口占用情况查看
  3. linux 取出字符中数字,使用awk提取字符串中的数字或字母
  4. 从一个数组中找出最接近目标_LeetCode每日一题 | 转变数组后最接近目标值的数组和...
  5. 华为鸿蒙系统智能手机_余承东再度确认:鸿蒙系统将适配到华为手机上
  6. matlab 条形图横坐标,Matlab条形图bar横坐标间距设置
  7. java ldap 分页_具有从属引用的 LDAP 分页查询未正确处理
  8. java实体字节属性定义_Java字节码方法表与属性表详解
  9. linux 中 timeval结构体
  10. open函数中O_CLOEXEC标志的开关