A - View Angle

Flatland has recently introduced a new type of an eye check for the driver's licence. The check goes like that: there is a plane with mannequins standing on it. You should tell the value of the minimum angle with the vertex at the origin of coordinates and with all mannequins standing inside or on the boarder of this angle.

As you spend lots of time "glued to the screen", your vision is impaired. So you have to write a program that will pass the check for you.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of mannequins.

Next n lines contain two space-separated integers each: xi, yi (|xi|, |yi| ≤ 1000) — the coordinates of the i-th mannequin. It is guaranteed that the origin of the coordinates has no mannequin. It is guaranteed that no two mannequins are located in the same point on the plane.

Output

Print a single real number — the value of the sought angle in degrees. The answer will be considered valid if the relative or absolute error doesn't exceed 10 - 6.

Examples

Input
  1. 2
    2 0
    0 2
Output
  1. 90.0000000000
Input
  1. 3
    2 0
    0 2
    -2 2
Output
  1. 135.0000000000
Input
  1. 4
    2 0
    0 2
    -2 0
    0 -2
Output
  1. 270.0000000000
Input
  1. 2
    2 1
    1 2
Output
  1. 36.8698976458

Note

Solution for the first sample test is shown below:

Solution for the second sample test is shown below:

Solution for the third sample test is shown below:

Solution for the fourth sample test is shown below:

就是给你一个二维平面的若干个点,让你选一个视角可以看到所有的点

我们可以考虑一下只有两个点的情况,就是最后一个点和第一个点形成的角度,另外的就是相邻两个的角度,但是要反着来啊,也就是补角。

我自己还傻乎乎的用atan写了一下atan2的实现

  1. #include<stdio.h>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. const double PI=acos(-.);
  5. const int N=1e5+;
  6. double a[N],x,y;
  7. int main()
  8. {
  9. int n;
  10. scanf("%d",&n);
  11. for(int i=; i<n; i++)scanf("%lf%lf",&x,&y),a[i]=*atan2(x,y)/PI;
  12. sort(a,a+n);
  13. double ans=a[n-]-a[];
  14. for(int i=; i<n; i++)ans=min(ans,+a[i-]-a[i]);
  15. printf("%.12f",ans);
  16. return ;
  17. }

B - Ghosts

Ghosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their way.

There are nn ghosts in the universe, they move in the OXYOXY plane, each one of them has its own velocity that does not change in time: V→=Vxi→+Vyj→V→=Vxi→+Vyj→ where VxVx is its speed on the xx-axis and VyVy is on the yy-axis.

A ghost ii has experience value EXiEXi, which represent how many ghosts tried to scare him in his past. Two ghosts scare each other if they were in the same cartesian point at a moment of time.

As the ghosts move with constant speed, after some moment of time there will be no further scaring (what a relief!) and the experience of ghost kind GX=∑ni=1EXiGX=∑i=1nEXiwill never increase.

Tameem is a red giant, he took a picture of the cartesian plane at a certain moment of time TT, and magically all the ghosts were aligned on a line of the form y=a⋅x+by=a⋅x+b. You have to compute what will be the experience index of the ghost kind GXGX in the indefinite future, this is your task for today.

Note that when Tameem took the picture, GXGX may already be greater than 00, because many ghosts may have scared one another at any moment between [−∞,T][−∞,T].

Input

The first line contains three integers nn, aa and bb (1≤n≤2000001≤n≤200000, 1≤|a|≤1091≤|a|≤109, 0≤|b|≤1090≤|b|≤109) — the number of ghosts in the universe and the parameters of the straight line.

Each of the next nn lines contains three integers xixi, VxiVxi, VyiVyi (−109≤xi≤109−109≤xi≤109, −109≤Vxi,Vyi≤109−109≤Vxi,Vyi≤109), where xixi is the current xx-coordinate of the ii-th ghost (and yi=a⋅xi+byi=a⋅xi+b).

It is guaranteed that no two ghosts share the same initial position, in other words, it is guaranteed that for all (i,j)(i,j) xi≠xjxi≠xj for i≠ji≠j.

Output

Output one line: experience index of the ghost kind GXGX in the indefinite future.

Examples

Input
  1. 4 1 1
    1 -1 -1
    2 1 1
    3 1 1
    4 -1 -1
Output
  1. 8
Input
  1. 3 1 0
    -1 1 0
    0 0 -1
    1 -1 -2
Output
  1. 6
Input
  1. 3 1 0
    0 0 0
    1 0 0
    2 0 0
Output
  1. 0

Note

There are four collisions (1,2,T−0.5)(1,2,T−0.5), (1,3,T−1)(1,3,T−1), (2,4,T+1)(2,4,T+1), (3,4,T+0.5)(3,4,T+0.5), where (u,v,t)(u,v,t) means a collision happened between ghosts uu and vv at moment tt. At each collision, each ghost gained one experience point, this means that GX=4⋅2=8GX=4⋅2=8.

In the second test, all points will collide when t=T+1t=T+1.

The red arrow represents the 1-st ghost velocity, orange represents the 2-nd ghost velocity, and blue represents the 3-rd ghost velocity.

这个题他们在群里讨论过,其实就是直接去做差,也就是a*vx-vy的值的问题,经过一次这个点也要+1

但是ans要爆int的,这个加起来就是等差数列求和

  1. #include<stdio.h>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. typedef long long ll;
  5. const double PI=acos(-.);
  6. map<ll,int>M;
  7. map<pair<int,int>,int>F;
  8. int main()
  9. {
  10. int n,a,b;
  11. long long ans=,t=;
  12. scanf("%d%d%d",&n,&a,&b);
  13. for(int i=,x,vx,vy; i<n; i++)
  14. {
  15. scanf("%d%d%d",&x,&vx,&vy);
  16. ans+=M[a*1LL*vx-vy]++;
  17. t+=F[make_pair(vx,vy)]++;
  18. }
  19. printf("%lld",*(ans-t));
  20. return ;
  21. }

台州学院we are without brain 训练 计算几何的更多相关文章

  1. 台州学院we are without brain 训练 后缀数组

    sa[i]表示排名为 i 的后缀的第一个字符在原串中的位置 rank[i]表示按照从小到大排名  以i为下标开始的后缀的排名 height[i]表示排名为 i 和排名为 i+1的后缀的最长公共前缀的长 ...

  2. 台州学院maximum cow训练记录

    前队名太过晦气,故启用最大牛 我们的组队大概就是18年初,组队阵容是17级生詹志龙.陶源和16级的黄睿博. 三人大学前均无接触过此类竞赛,队伍十分年轻.我可能是我们队最菜的,我只是知道的内容最多,靠我 ...

  3. LightOJ 1366 - Pair of Touching Circles (统计矩形内外切圆对)

    1366 - Pair of Touching Circles   PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limi ...

  4. LightOJ 1118 - Incredible Molecules (两圆面积交)

    1118 - Incredible Molecules   PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: ...

  5. 算法训练 Pollution Solution(计算几何)

    问题描述 作为水污染管理部门的一名雇员,你需要监控那些被有意无意倒入河流.湖泊和海洋的污染物.你的其中一项工作就是估计污染物对不同的水生态系统(珊瑚礁.产卵地等等)造成的影响. 你计算所使用的模型已经 ...

  6. 2018牛客网暑假ACM多校训练赛(第三场)I Expected Size of Random Convex Hull 计算几何,凸包,其他

    原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round3-I.html 题目传送门 - 2018牛客多校赛第三场 I ...

  7. 【2017多校训练2+计算几何+板】HDU 6055 Regular polygon

    http://acm.hdu.edu.cn/showproblem.php?pid=6055 [题意] 给定n个格点,问有多少个正多边形 [思路] 因为是格点,只可能是正方形 枚举正方形的对角线,因为 ...

  8. [知识点]计算几何I——基础知识与多边形面积

    // 此博文为迁移而来,写于2015年4月9日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102vxaq.html 1.前言 ...

  9. China Brain Project: Basic Neuroscience, Brain Diseases, and Brain-Inspired Computing

    日前,中国科学院神经科学研究所.中国科学院脑科学与智能技术卓越创新中心.香港科技大学生命科学部和分子神经科学国家重点实验室.中国科技大学自动化研究所在 Cell 上联合发表了一篇概述论文<Chi ...

随机推荐

  1. [选择排序] 时间复杂度O(n^2)

    思路:从未排序的序列中,找到最小的元素,放到序列的起始位置, 再从剩下没排序的里面,找到最小的,放到已经排序的末尾. 原地操作几乎是选择排序的唯一优点,当空间复杂度要求较高时,可以考虑选择排序:实际适 ...

  2. Android商城开发系列(六)——使用 OkHttpUtils 请求网络 + 使用 fastjson解析数据

    OkHttp是Google推荐使用的一个开源的网络请求框架,Android开发中涉及到网络请求和接口调用现在大部分都是使用OkHttp,网上已经有不少人针对OkHttp进行了封装,这里推荐一下鸿洋大神 ...

  3. UVALive 3942 Remember The Word (Tire)

    状态是DAG,因此方案用dp统计,dp[i] = sum(dp[i+len(x)]),x是以i开头的前缀且是单词,关键在于快速判断一个前缀是不是单词,可用Trie. 每一次转移的复杂度是O(maxle ...

  4. python之函数的初识

    1. 面向过程编程的缺点 代码重复 代码可可读性不高 2. 函数的定义*** ​ 函数是以功能为导向,一个函数封装一个功能.登录,注册,文件的改的操 3.函数的作用*** ​ 函数减少代码的重复性,增 ...

  5. 解读express框架

    #解读Express 框架 1. package.json文件:express工程的配置文件 2. 为什么可以执行npm start?相当于执行 node ./bin/www "script ...

  6. Xcode 的expression命令

    expression命令是执行一个表达式,并将表达式返回的结果输出,是LLDB调试命令中最重要的命令,也是我们常用的 p 和 po 命令的 鼻祖. 他主要有2个功能 (1) 执行表达式 举例:改变视图 ...

  7. 关于flyme5显示不到和卸载不到旧应用解决方法

    笔者买入一台mx5,升级flyme5后旧应用没有显示出来,而且在设置的应用管理都没显示旧应用. 通过adb命令: adb shell pm list packages显示所有包名, 查看自己要删除应用 ...

  8. 使用虚拟环境来管理python的包

    1.背景 在开发python项目的过程中,我们会用到各种各样的包,我们使用pip来管理包,请看下图我们刚装好python解释器时已安装的包: 但是随着我们疯狂的使用pip install xxx后,系 ...

  9. 【哈希 二分】bzoj2084: [Poi2010]Antisymmetry

    可以用manacher或者SA搞过去的:非常有趣的hash题 Description 对于一个01字符串,如果将这个字符串0和1取反后,再将整个串反过来和原串一样,就称作“反对称”字符串.比如0000 ...

  10. Git - revert详解

    git revert 撤销 某次操作,此次操作之前和之后的commit和history都会保留,并且把这次撤销作为一次最新的提交    * git revert HEAD                ...