QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#519059 | #9168. Square Locator | clear_tea | WA | 0ms | 3712kb | C++20 | 2.0kb | 2024-08-14 15:47:33 | 2024-08-14 15:47:37 |
Judging History
answer
#include <bits/stdc++.h>
#define int __int128
using ll = long long;
using namespace std;
mt19937_64 rnd(time(0));
//整数开方, 利用二分去查找
int sq(int x) {
int l = 0, r = 1e9 + 10;
while (r > 1 + l) {
int mid = (r + l) >> 1;
if (mid * mid <= x) l = mid;
else r = mid;
}
return l;
}
struct point {
int x, y;
// point(int x, int y): x(x), y(y){}
point clk90(point B) {
int dx = B.x - x;
int dy = B.y - y;
return {x + dy, y - dx};
}
point anti_clk90(point B) {
int dx = B.x - x;
int dy = B.y - y;
return {x - dy, y + dx};
}
int disSqr(point B) {
return (B.x - x) * (B.x - x) + (B.y - y) * (B.y - y);
}
};
int d1, d2, d3, d4;
point A, B, C, D;
void print(){
cout << (ll)A.y << " " << (ll)B.x << " " << (ll)B.y << " ";
cout << (ll)C.x << " " << (ll)C.y << " " << (ll)D.x << " " << (ll)D.y;
exit(0);
}
void check(int L) {
B.y = (d1 + d2 - L) / 2 / A.y;
B.x = sq(d2 - B.y * B.y);
C = B.clk90(A);
D = C.clk90(B);
if(C.disSqr({0,0}) == d3 && D.disSqr({0, 0}) == d4) print();
else{
B.x = -B.x;
C = B.clk90(A);
D = C.clk90(B);
if(C.disSqr({0,0}) == d3 && D.disSqr({0, 0}) == d4) print();
}
}
void solve() {
ll dd1, dd2, dd3, dd4;
cin >> dd1 >> dd2 >> dd3 >> dd4;
d1 = dd1, d2 = dd2, d3 = dd3, d4 = dd4;
A = {0, sq(dd1)};
int a = 2, b = -2 * (d2 + d4), c = (2 * d1 * d1 + d2 * d2 + d4 * d4 - 2 * d1 * d2 - 2 * d1 * d4);
int det = sq(b * b - 4 * a * c);
int x1 = (det - b) / 2 / a;
int x2 = (-1 * det - b) / 2 / a;
check(x1);
check(x2);
cout << "no ans";
}
signed main() {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll Tcase = 1;
// cin >> Tcase;
while (Tcase--) {
solve();
}
// ll a = 1e8, b = 1e8 + 1;
// cout << a * a << " " << 1 << " " << 1 + b*b << " " << a*a + b*b;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
36 5 10 41
output:
6 -2 1 3 -1 5 4
result:
ok Answer is correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
1 1 1 1
output:
1 -1 0 0 -1 1 0
result:
ok Answer is correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3704kb
input:
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
output:
no ans
result:
wrong output format Expected integer, but "no" found