QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#575590 | #3195. Within Arm's Reach | caijianhong | WA | 0ms | 4344kb | C++23 | 1.4kb | 2024-09-19 15:39:27 | 2024-09-19 15:39:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define debug(...) fprintf(stderr, ##__VA_ARGS__)
#else
#define endl "\n"
#define debug(...) void(0)
#endif
using LL = long long;
using point = complex<double>;
int n;
pair<double, int> b[30];
point tar, ans[30];
int main() {
#ifndef LOCAL
cin.tie(nullptr)->sync_with_stdio(false);
#endif
cin >> n;
int sum = 0;
for (int i = 1; i <= n; i++) cin >> b[i].first, sum += b[i].first, b[i].second = i;
{/*{{{*/
double tx, ty;
cin >> tx >> ty;
tar = point{tx, ty};
}/*}}}*/
if (sum > abs(tar)) {
sort(b + 1, b + n + 1);
double pre = 0;
for (int i = 1; i <= n; i++) {
pre += b[i].first;
int id = b[i].second;
if (sum - pre * 2 <= abs(tar)) {
double a = b[i].first, b = pre - a + abs(tar), c = sum - pre;
double angc = acos((a * a + b * b - c * c) / (2 * a * b));
point tmp = ans[id] = polar(a, angc);
point all = (b - tmp) / c;
for (int j = i + 1; j <= n; j++) ans[::b[j].second] = all * ::b[j].first;
break;
}
ans[b[i].second] = -b[i].first;
}
} else {
for (int i = 1; i <= n; i++) ans[b[i].second] = b[i].first;
}
point now = 0;
cout << fixed << setprecision(6);
for (int i = 1; i <= n; i++) {
now += ans[i] * polar(1., arg(tar));
cout << real(now) << " " << imag(now) << endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4344kb
input:
2 4 2 -8 -3
output:
-3.745317 -1.404494 -5.617975 -2.106741
result:
ok ACCEPTED
Test #2:
score: 0
Accepted
time: 0ms
memory: 3988kb
input:
1 10 10 0
output:
10.000000 0.000000
result:
ok ACCEPTED
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 4044kb
input:
1 10 0 0
output:
nan nan
result:
wrong output format Expected double, but "nan" found