当前位置:网站首页>[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;
}
边栏推荐
- C# 窗体应用TreeView控件使用
- Introduction to WDK development 1- basic environment construction and the first driver (VS2010)
- Richview table table alignment
- [leetcode] 1184. Distance between bus stops
- clip:learning transferable visual models from natural language supervision
- MySQL stored procedure
- Istio一之Envoy工作原理
- 02 | 环境准备:如何在windows下安装和配置一个基本的php开发环境?
- "Hualiu is the top stream"? Share your idea of yyds
- VLAN Technology
猜你喜欢

Apache atlas version 2.2 installation

Lunch break train & problem thinking: thinking about the problem of converting the string formed by hour: minute: second to second

strlen函数剖析和模拟实现

English grammar_ Demonstrative pronoun this / these / that / those

(posted) differences and connections between beanfactory and factorybean

Description of large and small end mode

YouTube "label products" pilot project launched

From code farmer to great musician, you only need these music processing tools

Create a life cycle aware MVP architecture

Talk about your transformation test development process
随机推荐
02 | environment preparation: how to install and configure a basic PHP development environment under windows?
How to select software dongle
Solve the problem of error l6218e undefined symbol XXX
Login Huawei device in SSH mode
Write a batch and start redis
TCP sliding window, singleton mode (lazy and hungry) double checked locking / double checked locking (DCL)
Choose the appropriate container runtime for kubernetes
Detailed explanation of ELF format (I)
[face to face experience of school recruitment] 8 real questions of pointer interview. Come and test how many you have mastered.
Expression evaluation (stack)
英文翻译中文常见脏话
Introduction and advanced tutorial of Albert duilib
02 | 环境准备:如何在windows下安装和配置一个基本的php开发环境?
Sword finger offer 50. the first character that appears only once
01 | 开篇词:手把手教你搭建一个博客网站
147-利用路由元信息设置是否缓存——include和exclude使用——activated和deactivated的使用
strlen函数剖析和模拟实现
《自尊的6大支柱》自尊来源于自身的感受
Analysis and Simulation of strlen function
Connect the smart WiFi remote control in the home assistant