QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#53898 | #4838. Rotate Sum 2 | zhoukangyang# | WA | 2ms | 4080kb | C++11 | 1.2kb | 2022-10-06 11:38:22 | 2022-10-06 11:38:24 |
Judging History
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int >
#define me(a, x) memset(a, x, sizeof(a))
#define ull unsigned long long
#define ld __float128
using namespace std;
const int N = 1e6 + 7;
double x[N], y[N];
int n;
const double pi = acos(-1);
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
double s = 0;
L(i, 1, n) {
cin >> x[i] >> y[i];
}
L(i, 1, n) {
s += x[i] * y[i % n + 1] - x[i % n + 1] * y[i];
}
s /= 2;
double ns = 0, tmp = 0, all = 0, qx = 0, qy = 0;
L(i, 1, n) all += x[i] * x[i], qx += x[i], qy += y[i];
L(i, 1, n) {
int lst = (i + n - 2) % n + 1, nxt = i % n + 1;
double qc = atan2(y[lst] - y[i], x[lst] - x[i]) - atan2(y[nxt] - y[i], x[nxt] - x[i]);
if(qc < 0) qc += pi * 2;
double w = pi - qc;
tmp += w;
double qwq = 0;
qwq -= 2 * qx * x[i];
qwq -= 2 * qy * y[i];
qwq += all * n;
qwq += (x[i] * x[i] + y[i] * y[i]) * n;
ns += qwq * w;
}
cout.precision(12), cout << fixed;
cout << ns / n / 2 + s * (n - 2) << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 4080kb
input:
3 1 -1 1 1 -1 2
output:
18.763234503174
result:
ok found '18.76323', expected '18.76323', error '0.00000'
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 4052kb
input:
4 -1000000000 1000000000 -1000000000 -1000000000 1000000000 -1000000000 1000000000 1000000000
output:
26849555921538760704.000000000000
result:
wrong answer 1st numbers differ - expected: '16566370614359173120.00000', found: '26849555921538760704.00000', error = '0.62073'