当前位置:网站首页>Helix distance of point
Helix distance of point
2022-06-24 23:26:00 【Stay--hungry】

Ideas :
For point A ( x , y ) A(x,y) A(x,y), First, determine which area the point belongs to

Then find out where the point is “ ray ” The endpoint of B ( a , b ) B(a,b) B(a,b)( find Endpoint coordinates and ( x , y ) (x,y) (x,y) The relationship between )

Looking for a regular , Find out B B B The distance to the origin ∣ B O ∣ |BO| ∣BO∣

seek ∣ A O ∣ |AO| ∣AO∣ Turn into : ∣ A O ∣ = ∣ B O ∣ + ∣ A B ∣ |AO|=|BO|+|AB| ∣AO∣=∣BO∣+∣AB∣
#include <iostream>
using namespace std;
typedef long long LL;
int main()
{
int x, y;
cin >> x >> y;
int a, b; // Endpoint coordinates of rays
LL d; // The distance from the endpoint to the origin
if (-y <= x && x <= y) // On the top
{
a = -y, b = y;
d = (LL)2 * abs(a) * (2 * abs(a) - 1);
cout << d + x - a;
}
else if (-x <= y && y <= x) // On the right
{
a = x, b = x;
d = (LL)2 * a * 2 * a;
cout << d + b - y;
}
else if (y - 1 <= x && x <= -y) // Below
{
a = -y, b = y;
d = (LL)2 * abs(a) * (2 * abs(a) + 1);
cout << d + a - x;
}
else // On the left
{
a = x, b = x + 1;
d = (LL)(2 * abs(a) - 1) * (2 * abs(a) - 1);
cout << d + y - b;
}
return 0;
}
边栏推荐
- R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用AIC函数比较两个模型的AIC值的差异(简单模型和复杂模型)
- 安装IBM CPLEX学术版 academic edition | conda 安装 CPLEX
- F29oc analysis
- Construction equipment [6]
- Financial management [4]
- 22map introduction and API
- 去处电脑桌面小箭头
- 03_ Spingboot core profile
- Record the range of data that MySQL update will lock
- websocket长链接压测
猜你喜欢
Paddledtx v1.0 has been released, and its security and flexibility have been comprehensively improved!

idea创建模块提示已存在

Laravel pagoda security configuration
![[JS] - [array, Stack, queue, Link List basis] - Notes](/img/c6/a1bd3b8ef6476d7d549abcb442949a.png)
[JS] - [array, Stack, queue, Link List basis] - Notes

选择类排序法

File contains vulnerability issues

03_ Spingboot core profile

企业数据防泄露解决方案分享

国内有哪些好的智能家居品牌支持homekit?

SimpleDateFormat 格式化和解析日期的具体类
随机推荐
sql -CONVERT函数
Financial management [1]
golang convert map to json string
Bubble sort
golang convert json string to map
379. 捉迷藏
[JS] - [linked list - application] - learning notes
OpenSSL SSL_read: Connection was reset, errno 10054
[basic knowledge] ~ half adder & full adder
Laravel user authorization
【基础知识】~ 半加器 & 全加器
Ganglia 的安装与部署
#22Map介绍与API
websocket长链接压测
OpenSSL SSL_ read: Connection was reset, errno 10054
Laravel add helper file
From client to server
【js】-【栈、队-应用】-学习笔记
Case analysis: using "measurement" to improve enterprise R & D efficiency | ones talk
. Net 7 Preview 1 has been officially released