2 条题解
-
0
计算几何通用解法:
#include <bits/stdc++.h> using u32 = unsigned; using i64 = long long; using u64 = unsigned long long; using i128 = __int128; constexpr double PI = acos(-1); struct Point { double x, y; }; // 绕原点顺时针旋转b(弧度制)角度 Point rotate(Point a, double b) { return {a.x * cos(b) + a.y * sin(b), -a.x * sin(b) + a.y * cos(b)}; } void solve() { double a, b, c, d; std::cin >> a >> b >> c >> d; Point A = {a, b}, B = {c, d}; // 将A作为 y 坐标小的,方便我们平移到原点 if (b > d) { std::swap(A, B); } double dx = A.x, dy = A.y; A.x = A.y = 0; B.x -= dx, B.y -= dy; // 接下来让 B 点顺逆时针旋转60度 Point C = rotate(B, 60 * PI / 180); Point D = rotate(B, -60 * PI / 180); if (C.x == round(C.x) && C.y == round(C.y)) { std::cout << C.x + dx << " " << C.y + dy << "\n"; } else if (D.x == round(D.x) && D.y == round(D.y)) { std::cout << D.x + dx << " " << D.y + dy << "\n"; } else { std::cout << -1 << "\n"; } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout << std::fixed << std::setprecision(4); int t; std::cin >> t; while (t --) { solve(); } return 0; }
-
0
其实这是一道陷阱题,我们计算等边三角形的第三个点的时候计算公式中包含 ,另外两个点的 均为整数,只要乘以 必为无理数,不可能为整数,所以答案全输出 。
#include <bits/stdc++.h> #define vi vector<int> #define vpi vector<pair<int, int>> using namespace std; using ll = long long; constexpr int N = 110; void solve() { cout << -1 << endl; } signed main() { int T = 1; cin >> T; while(T --) solve(); }
- 1
信息
- ID
- 93
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 33
- 已通过
- 14
- 上传者