2023牛客寒假算法基础集训营3 -- E-公平守望的灯塔(向量 简单几何)
创始人
2024-05-14 22:51:08

题目如下:

在这里插入图片描述

示例1

输入
1 0 0 1

输出

0 0

说明

输出1 1也是可以的。

思路 or 题解:

我们可以迅速找到 CCC 有两个位置满足题意,但 CCC 的坐标不一定是整数,我们需要 checkcheckcheck
在这里插入图片描述
MMM 是 ABABAB 的中点
我们可以求出来 AM→\overrightarrow{AM}AM, MC1→\overrightarrow{MC_1}MC1​​, MC2→\overrightarrow{MC_2}MC2​
通过向量我们可以求出 C1,C2C_1, C_2C1​,C2​ 的坐标,最后 checkcheckcheck 一下就行了

注意:

为了在计算中不出现分数,我们可以把坐标均乘以 222, 最后答案坐标 除以 222 即可。

AC 代码如下:

/*
Make it simple and keep self stupid
author:Joanh_Lan
*/
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define buff                     \ios::sync_with_stdio(false); \cin.tie(0);
#define int long long
#define ll long long
#define PII pair
#define px first
#define py second
typedef std::mt19937 Random_mt19937;
Random_mt19937 rnd(time(0));
using namespace std;
const int mod = 1e9 + 7;
const int inf = 2147483647;
const int N = 100009;
//int Mod(int a,int mod){return (a%mod+mod)%mod;}
//int lowbit(int x){return x&-x;}//最低位1及其后面的0构成的数值
//int qmi(int a, int k, int p){int res = 1 % p;while (k){if (k & 1) res = Mod(res * a , p);a = Mod(a * a , p);k >>= 1;}return res;}
//int inv(int a,int mod){return qmi(a,mod-2,mod);}
//int lcm(int a,int b){return a*b/__gcd(a,b);}
void solve()
{int x1, x2, y1, y2;cin >> x1 >> y1 >> x2 >> y2;x1 *= 2, x2 *= 2, y1 *= 2, y2 *= 2;int mx = (x1 + x2) / 2ll, my = (y1 + y2) / 2ll;int detla_x = mx - x1, detla_y = my - y1;if ((detla_y + mx) % 2ll == 0 && (-detla_x + my) % 2ll == 0)cout << (detla_y + mx) / 2ll << ' ' << (-detla_x + my) / 2ll << '\n';else if((-detla_y + mx) == 0 && (detla_x + my) % 2 == 0)cout << (-detla_y + mx) / 2ll << ' ' << (detla_x + my) / 2ll << '\n';elsecout << "No Answer!\n";
}
signed main()
{buff;solve();
}

相关内容

热门资讯

阿西吧是什么意思 阿西吧相当于... 即使你没有受到过任何外语培训,你也懂四国语言。汉语:你好英语:Shit韩语:阿西吧(아,씨발! )日...
猫咪吃了塑料袋怎么办 猫咪误食... 你知道吗?塑料袋放久了会长猫哦!要说猫咪对塑料袋的喜爱程度完完全全可以媲美纸箱家里只要一有塑料袋的响...
世界上最漂亮的人 世界上最漂亮... 此前在某网上,选出了全球265万颜值姣好的女性。从这些数量庞大的女性群体中,人们投票选出了心目中最美...
北京的名胜古迹 北京最著名的景... 北京从元代开始,逐渐走上帝国首都的道路,先是成为大辽朝五大首都之一的南京城,随着金灭辽,金代从海陵王...