HBC24771管管的幸运数字,二分,分治,数论[USACO 2010 Ope G]Triangle Counting题解

惰性的成熟 算法基础篇 40 0
全网最全C++题库,助您快速提升编程技能!题库丰富多样,涵盖各个领域,让您在练习中不断成长!
Bessie is standing guard duty after the big bad wolf was spotted stalking cows over at Farmer Don's spread.Looking down from her guard tower in utter boredom, she's decided to perform intellectual exercises in order to keep awake. After imagining the field as an X,Y grid, she recorded the coordinates of the N (1

Bessie is standing guard duty after the big bad wolf was spotted stalking cows over at Farmer Don's spread. Looking down from her guard tower in utter boredom, she's decided to perform intellectual exercises in order to keep awake. After imagining the field as an X,Y grid, she recorded the coordinates of the N (1 <= N <= 100,000) conveniently numbered 1..N cows as X_i,Y_i X i ​ ,Y i ​ (-100,000 <= X_i X i ​ <= 100,000; -100,000 <= Y_i Y i ​ <= 100,000; 1 <= i <= N). She then mentally formed all possible triangles that could be made from subsets of the entire set of cow coordinates. She counts a triangle as 'golden' if it wholly contains the origin (0,0). The origin does not fall on the line between any pair of cows. Additionally, no cow is standing exactly on the origin. Given the list of cow locations, calculate the number of 'golden' triangles that contain the origin so Bessie will know if she's doing a good job. By way of example, consider 5 cows at these locations: -5,0 0,2 11,2 -11,-6 11,-5 Below is a schematic layout of the field from Betsy's point of view: ............|............ ............*..........*. ............|............ -------*----+------------ ............|............ ............|............ ............|............ ............|............ ............|..........*. .*..........|............ ............|............ All ten triangles below can be formed from the five points above: By inspection, 5 of them contain the origin and hence are 'golden'.

HBC24771管管的幸运数字,二分,分治,数论[USACO 2010 Ope G]Triangle Counting题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
成为编程大师,不再是梦想!全网最全C++题库,助您开启编程新篇章。

标签: HBC24771管管的幸运数字 二分 分治 数论[USACO 2010 Ope G]Triangle Counting题解