QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#58003#4838. Rotate Sum 2MIT01#WA 3ms3928kbC++17900b2022-10-24 08:47:092022-10-24 08:47:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-24 08:47:12]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3928kb
  • [2022-10-24 08:47:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

constexpr const double PI = acos(-1.0);
ll x[100005], y[100005];
ll sx2, sx, sy2, sy;
double ans1, ans2;
int n;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", x+i, y+i);
    sx2 += x[i]*x[i], sx += x[i];
    sy2 += y[i]*y[i], sy += y[i];
  }
  x[n] = x[0], y[n] = y[0];
  x[n+1] = x[1], y[n+1] = y[1];

  // area of polygon
  for (int i = 0; i < n; i++) {
    ans1 += x[i]*y[i+1]-x[i+1]*y[i];
  }
  ans1 /= 2;

  // sectors
  for (int i = 1; i <= n; i++) {
    double dot = (x[i+1]-x[i])*(x[i-1]-x[i]) + (y[i+1]-y[i])*(y[i-1]-y[i]);
    double angle = acos(dot / hypot(x[i+1]-x[i], y[i+1]-y[i]) / hypot(x[i-1]-x[i], y[i-1]-y[i]));
    ans2 += (PI - angle) * (n*x[i]*x[i] + n*y[i]*y[i] - 2*sx*x[i] - 2*sy*y[i] + sx2 + sy2);
  }
  ans2 /= 2*n;

  printf("%.17lf\n", ans1+ans2);
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3888kb

input:

3
1 -1
1 1
-1 2

output:

18.76323450317391917

result:

ok found '18.76323', expected '18.76323', error '0.00000'

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3928kb

input:

4
-1000000000 1000000000
-1000000000 -1000000000
1000000000 -1000000000
1000000000 1000000000

output:

2078331698204927232.00000000000000000

result:

wrong answer 1st numbers differ - expected: '16566370614359173120.00000', found: '2078331698204927232.00000', error = '0.87455'