QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#575590#3195. Within Arm's ReachcaijianhongWA 0ms4344kbC++231.4kb2024-09-19 15:39:272024-09-19 15:39:27

Judging History

你现在查看的是最新测评结果

  • [2024-09-19 15:39:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4344kb
  • [2024-09-19 15:39:27]
  • 提交

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