QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#807899 | #9869. Horizon Scanning | zzfs# | WA | 49ms | 4264kb | C++17 | 898b | 2024-12-10 14:23:33 | 2024-12-10 14:23:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define max_len 200010
double arr[max_len];
int N;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
double get_cha(double beg, double end)
{
if(beg <= end)
{
return end - beg;
}
else
{
return 2 * M_PI + end - beg;
}
}
void sol()
{
int k;
cin >> N >> k;
for (int i = 0; i < N; i++)
{
int a, b;
cin >> a >> b;
arr[i] = atan2(a, b);
}
sort(arr, arr + N);
if(N == k)
{
printf("%.8lf\n", M_PI * 2);
return;
}
double ans = 0;
for (int i = 0; i < N; i++)
{
ans = max(ans, get_cha(arr[i], arr[(i + k) % N]));
}
//cout << ans << "\n";
printf("%.8lf\n", ans);
}
int main()
{
int T;
cin >> T;
while (T--)
{
sol();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4152kb
input:
5 1 1 0 1 8 2 1 0 1 1 0 1 -1 1 -1 0 -1 -1 0 -1 1 -1 4 2 -1 1 0 1 0 2 1 1 4 2 -1000000000 0 -998244353 1 998244353 1 1000000000 0 3 1 0 1 0 2 0 -1
output:
6.28318531 1.57079633 5.49778714 3.14159265 3.14159265
result:
ok 5 numbers
Test #2:
score: -100
Wrong Answer
time: 49ms
memory: 4264kb
input:
10000 16 1 -10 -6 -5 -6 -4 9 -2 5 -2 10 1 -7 1 -5 1 6 3 1 4 -9 6 -10 6 -3 6 1 8 -5 8 -4 9 -4 17 4 -9 2 -8 -4 -8 -3 -8 -1 -6 -2 -6 -1 -6 8 -5 -8 -5 10 -4 8 -2 -8 4 -9 4 0 5 -3 8 -5 9 -2 10 10 10 6 -7 2 -4 6 -2 -7 -2 -1 -1 7 1 -9 1 8 3 -4 7 -4 9 -2 14 3 -9 10 -8 -10 -8 -8 -6 -7 -6 -5 -1 -7 -1 -2 0 -1 ...
output:
1.69299150 2.57486344 4.65275827 2.77263311 5.74276581 4.85769899 3.41989231 2.81279996 6.28318531 6.28318531 5.11728077 6.14678270 3.84208902 2.34249672 3.46334321 6.28318531 5.96143475 3.32470347 5.26277493 5.67245934 1.67387794 1.11419085 2.40877755 6.28318531 5.35589009 3.79986062 4.19324287 4.0...
result:
wrong answer 42nd numbers differ - expected: '6.2831853', found: '6.2599337', error = '0.0037006'