QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#58016#4838. Rotate Sum 2MIT01#Compile Error//C++1.0kb2022-10-24 09:50:412022-10-24 09:50:42

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 09:50:42]
  • 评测
  • [2022-10-24 09:50:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define db long double
constexpr const long double PI = acosl(-1.0L);
long double x[100005], y[100005];
long double sx2, sx, sy2, sy;
long double ans1, ans2;
int n;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%Lf%Lf", 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++) {
    long double dot = (x[i+1]-x[i])*(x[i-1]-x[i]) + (y[i+1]-y[i])*(y[i-1]-y[i]);
db cur = dot / hypotl(x[i+1]-x[i], y[i+1]-y[i]) / hypotl(x[i-1]-x[i], y[i-1]-y[I]);
if (cur > 1) cur = 1;
if (cur < -1) cur = -1;
    long double angle = acosl(cur);
    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;
}

详细

answer.code: In function ‘int main()’:
answer.code:29:80: error: ‘I’ was not declared in this scope
   29 | db cur = dot / hypotl(x[i+1]-x[i], y[i+1]-y[i]) / hypotl(x[i-1]-x[i], y[i-1]-y[I]);
      |                                                                                ^
answer.code:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
answer.code:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%Lf%Lf", x+i, y+i);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~