当前位置:网站首页>[training Day6] triangle [mathematics] [violence]
[training Day6] triangle [mathematics] [violence]
2022-07-24 20:10:00 【VL——MOESR】

Ideas :
We consider the properties of right triangle
Turn at a right angle 90° The slope of is equal to the slope of the other right angle side
Then we can enumerate right angle vertices , Turn each side 90° Slope of map Save up , Just make the final statistics
c o d e code code
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
const int MAXN = 1510;
int n, sum;
map<pair<int, double>, int> q;
struct node {
int x, y;
}a[MAXN];
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; i ++) scanf("%d%d", &a[i].x, &a[i].y);
for(int i = 1; i <= n; i ++) {
int x = 0, y = 0;
for(int j = 1; j <= n; j ++)
if(i != j) a[j].x -= a[i].x, a[j].y -= a[i].y;
for(int j = 1; j <= n; j ++) {
if(i != j) {
int x1 = -a[j].y, y1 = a[j].x, g;
double k = (y1 - y) * 1.0 / (x1 * 1.0 - x * 1.0);
if(k < -1000000000 || k > 1000000000)
k = 10000000000.0;
if(x1 > 0 && y1 >= 0) g = 1;
if(x1 <= 0 && y1 > 0) g = 2;
if(x1 < 0 && y1 <= 0) g = 3;
if(x1 >= 0 && y1 < 0) g = 4;
q[make_pair(g, k)] ++;
// cout<<g<<' '<<k<<endl;
}
}
// cout<<"-----------"<<endl;
for(int j = 1; j <= n; j ++) {
if(i != j) {
int x1 = a[j].x, y1 = a[j].y, g;
double k = (y - y1) * 1.0 / (x * 1.0 - x1 * 1.0);
if(k < -1000000000 || k > 1000000000)
k = 10000000000.0;
if(x1 > 0 && y1 >= 0) g = 1;
if(x1 <= 0 && y1 > 0) g = 2;
if(x1 < 0 && y1 <= 0) g = 3;
if(x1 >= 0 && y1 < 0) g = 4;
sum += q[make_pair(g, k)];
// cout<<g<<' '<<k<<endl;
}
}
// cout<<endl<<sum<<endl;
q.clear();
// cout<<endl<<"----------"<<endl<<"__________"<<endl;
for(int j = 1; j <= n; j ++)
if(i != j) a[j].x += a[i].x, a[j].y += a[i].y;
}
printf("%d", sum);
return 0;
}
边栏推荐
- Introduction and advanced tutorial of Albert duilib
- Hcip early summary
- clip:learning transferable visual models from natural language supervision
- 2019 Hangdian multi school first 6581 vacation [thinking]
- Description of large and small end mode
- Hold the C pointer
- (posted) differences and connections between beanfactory and factorybean
- Sword finger offer 48. the longest substring without repeated characters
- Conversion between VC string and timestamp
- Machine learning job interview summary: five key points that resume should pay attention to
猜你喜欢

Lunch break train & problem thinking: on multidimensional array statistics of the number of elements
![[face to face experience of school recruitment] 8 real questions of pointer interview. Come and test how many you have mastered.](/img/2c/e687b224285aeee66dacace6331161.png)
[face to face experience of school recruitment] 8 real questions of pointer interview. Come and test how many you have mastered.

ATL container - catlmap, crbmap

Valdo2021 - vascular space segmentation in vascular disease detection challenge (3)

Elastomer simulation (elasticity)

Istio一之Envoy工作原理

Login Huawei device in SSH mode

Getting started with COM programming 1- creating projects and writing interfaces

Thinking of @requestbody caused by hi and hello requests

Valdo2021 - vascular space segmentation in vascular disease detection challenge (I)
随机推荐
Stop using UUID indiscriminately. Have you tested the performance gap between self incrementing ID and UUID?
Istio II traffic hijacking process
TCP sliding window, singleton mode (lazy and hungry) double checked locking / double checked locking (DCL)
MySQL advanced 2
Duilib actual combat 1- imitate Baidu online disk login interface
How to use the interface control telerik UI for WinForms development step progress bar?
Leetcode 146: LRU cache
How to export map files tutorial
【LeetCode】1184. 公交站间的距离
Valdo2021 - vascular space segmentation in vascular disease detection challenge (3)
Introduction to WDK development 1- basic environment construction and the first driver (VS2010)
How to select software dongle
01 | opening words: teach you to build a blog website hand in hand
Work notes - some problems encountered when using jest
Hide the middle digit of ID number
Mysql8.0 learning record 19 - Page segments and tablespaces
Click the button to return to the top smoothly
strlen函数剖析和模拟实现
Talk about your transformation test development process
Analysis and Simulation of strlen function