QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#841614 | #9869. Horizon Scanning | hanmx | AC ✓ | 79ms | 6320kb | C++17 | 33.0kb | 2025-01-03 21:06:58 | 2025-01-03 21:07:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using i64=long long;
using u64=unsigned long long;
using i128=__int128;
#define equals(a,b) (fabs((a) - (b))< eps ) //精度内相等
const double inf = 1e20; //最大值
const double eps = 1e-8; //精度
const double pi = acos(-1.0);
const int maxp = 2010; //注意题目范围
double truevalue(double x) {// 去0
if (fabs(x)<eps) return 0;
else return x;
}
int sgn(double x){// 判断正负0
if(fabs(x)<eps) return 0;
if(x<0) return -1;
else return 1;
}
int dcmp(double x,double y){// 比较数字
if(fabs(x-y)<eps) return 0;
if(x<y) return -1;
return 1;
}
//点,向量
template<class T>
struct Point{
T x,y;
Point(const T &x_=0,const T &y_=0):x(x_),y(y_){}
template<class U>
operator Point<U>(){
return Point<U>(U(x),U(y));
}
//返回长度
T len() {
return hypot(x, y);
}
T len2(){
return x*x+y*y;
}
Point<T> trunc(T r) {//转化为长度为r的同向向量
T l = len();
if (!sgn(l)) return *this;
r /= l;
return Point<T>(x * r, y * r);
}
//逆时针旋转 90 度
Point<T> rotleft() {
return Point<T>(-y, x);
}
//顺时针旋转 90 度
Point<T> rotright() {
return Point<T>(y, -x);
}
//绕着 p 点逆时针旋转 angle
Point<T> rotate(Point<T> p, T angle) {
Point<T> v = (*this) - p;
T c = cos(angle), s = sin(angle);
return Point<T>(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);
}
Point<T> pointtruevalue() {//精度值以内
Point<T> a;
a.x = truevalue(x);
a.y = truevalue(y);
return a;
}
// 以下均为重载运算符
bool operator==(const Point<T> &a)const{
return sgn(x-a.x)==0&&sgn(y-a.y)==0;
}
bool operator!=(const Point<T> &a)const{
return sgn(x-a.x)!=0||sgn(y-a.y)!=0;
}
Point<T> &operator+=(const Point<T> &a)&{
x+=a.x;
y+=a.y;
return *this;
}
Point<T> &operator-=(const Point<T> &a)&{
x-=a.x;
y-=a.y;
return *this;
}
Point<T> &operator*=(const T &a)&{
x*=a;
y*=a;
return *this;
}
Point<T> &operator/=(const T &a)&{
x/=a;
y/=a;
return *this;
}
Point<T> operator-()const{
return Point<T>(-x,-y);
}
friend Point<T> operator+(Point<T> a, const Point<T> &b) {
return a+=b;
}
friend Point<T> operator-(Point<T> a, const Point<T> &b) {
return a -= b;
}
friend Point<T> operator*(Point<T> a, const T &b) {
return a *= b;
}
friend Point<T> operator/(Point<T> a, const T &b) {
return a /= b;
}
friend Point<T> operator*(const T &a, Point<T> b) {
return b *= a;
}
friend std::istream &operator>>(std::istream &is, Point<T> &p) {
return is >> p.x >> p.y;
}
friend std::ostream &operator<<(std::ostream &os, const Point<T> &p) {
return os << "(" << p.x << ", " << p.y << ")";
}
};
template<class T>// 点的相对位置排序
int sgn(const Point<T> &a) {
return a.y > 0 || (a.y == 0 && a.x > 0)? 1 : -1;
}
template<class T>//点乘
T dot(const Point<T> &a, const Point<T> &b) {
return a.x * b.x + a.y * b.y;
}
template<class T>//叉乘
T cross(const Point<T> &a, const Point<T> &b) {
return a.x * b.y - a.y * b.x;
}
template<class T>//叉乘
T cross(Point<T> &A, Point<T> &B, Point<T> &C) {
return cross((B - A) , (C - A));
}
template<class T>//点乘
T dot(Point<T> &A, Point<T> &B, Point<T> &C) {
return dot((B - A) , (C - A));
}
template<class T>//求pa与pb的夹角
double rad(const Point<T> &p,const Point<T> &a, const Point<T> &b){
return fabs(atan2(fabs(cross((a - p),(b - p))), dot((a - p),(b - p))));
}
template<class T>// 求向量的夹角
T rad(Point<T> &a){
return atan2(a.y,a.x);
}
template<class T>//向量长度平方
T square(const Point<T> &p) {
return dot(p, p);
}
template<class T>//向量长度
double length(const Point<T> &p) {
return std::sqrt(square(p));
}
template<class T>//单位向量
Point<T> norms(const Point<T> &p) {
return p / length(p);
}
template<class T>//两点距离
double distance(const Point<T> &a, const Point<T> &b) {
return length(a - b);
}
// 线
template<class T>
struct Line {
Point<T> a;
Point<T> b;
Line(const Point<T> &a_ = Point<T>(), const Point<T> &b_ = Point<T>()) : a(a_), b(b_) {}
};
template<class T>// 投影向量
Point<T> projection(const Point<T> &p, const Line<T> &l) {
return l.a + (l.b - l.a) * dot(l.b - l.a, p - l.a) / square((l.b - l.a));
}
template<class T> // 点关于直线对称
Point<T> reflection(const Point<T> &p, const Line<T> &l) {
return p + (projection(p, l) - p) * T(2);
}
template<class T>//线长度
double length(const Line<T> &l) {
return length(l.a - l.b);
}
template<class T>//判断线是否平行,平行返回1
bool parallel(const Line<T> &l1, const Line<T> &l2) {
return cross(l1.b - l1.a, l2.b - l2.a) == 0;
}
template<class T>//点到直线的距离
double distancePL(const Point<T> &p, const Line<T> &l) {
return std::abs(cross(l.a - l.b, l.a - p)) / length(l);
}
template<class T>//点到线段的距离
double distancePS(const Point<T> &p, const Line<T> &l) {
if (dot(p - l.a, l.b - l.a) < 0) {
return distance(p, l.a);
}
if (dot(p - l.b, l.a - l.b) < 0) {
return distance(p, l.b);
}
return distancePL(p, l);
}
template<class T>//判断一个点与直线的位置
int pointOnLine(const Point<T> &p, const Line<T> &l) {
T x=cross(l.b - l.a, p - l.a);
if(sgn(x)>0) return 1;//左
else if(sgn(x)<0) return 2;//右
else return 0;//在线段上
}
template<class T>//判断点是否在线段上
bool pointOnSegment(const Point<T> &p, const Line<T> &l) {
return cross(p - l.a, l.b - l.a) == 0 && std::min(l.a.x, l.b.x) <= p.x && p.x <= std::max(l.a.x, l.b.x)
&& std::min(l.a.y, l.b.y) <= p.y && p.y <= std::max(l.a.y, l.b.y);
}
template<class T>// 两直线的交点
Point<T> lineIntersection(const Line<T> &l1, const Line<T> &l2) {
return l1.a + (l1.b - l1.a) * (cross(l2.b - l2.a, l1.a - l2.a) / cross(l2.b - l2.a, l1.a - l1.b));
}
template<class T>//点是否在多边形内部
bool pointInPolygon(const Point<T> &a, const std::vector<Point<T>> &p) {
int n = p.size();
for (int i = 0; i < n; i++) {
if (pointOnSegment(a, Line(p[i], p[(i + 1) % n]))) {
return true;
}
}
int t = 0;
for (int i = 0; i < n; i++) {
auto u = p[i];
auto v = p[(i + 1) % n];
if (u.x < a.x && v.x >= a.x && pointOnLineLeft(a, Line(v, u))) {
t ^= 1;
}
if (u.x >= a.x && v.x < a.x && pointOnLineLeft(a, Line(u, v))) {
t ^= 1;
}
}
return t == 1;
}
template<class T>// 两条线段
// 0 : 完全不相交
// 1 : 严格相交,交点在线段内部
// 2 : 线段部分重叠
// 3 : 线段在端点处相交
std::tuple<int, Point<T>, Point<T>> segmentIntersection(const Line<T> &l1, const Line<T> &l2) {
if (std::max(l1.a.x, l1.b.x) < std::min(l2.a.x, l2.b.x)) {
return {0, Point<T>(), Point<T>()};
}
if (std::min(l1.a.x, l1.b.x) > std::max(l2.a.x, l2.b.x)) {
return {0, Point<T>(), Point<T>()};
}
if (std::max(l1.a.y, l1.b.y) < std::min(l2.a.y, l2.b.y)) {
return {0, Point<T>(), Point<T>()};
}
if (std::min(l1.a.y, l1.b.y) > std::max(l2.a.y, l2.b.y)) {
return {0, Point<T>(), Point<T>()};
}
if (cross(l1.b - l1.a, l2.b - l2.a) == 0) {
if (cross(l1.b - l1.a, l2.a - l1.a) != 0) {
return {0, Point<T>(), Point<T>()};
} else {
auto maxx1 = std::max(l1.a.x, l1.b.x);
auto minx1 = std::min(l1.a.x, l1.b.x);
auto maxy1 = std::max(l1.a.y, l1.b.y);
auto miny1 = std::min(l1.a.y, l1.b.y);
auto maxx2 = std::max(l2.a.x, l2.b.x);
auto minx2 = std::min(l2.a.x, l2.b.x);
auto maxy2 = std::max(l2.a.y, l2.b.y);
auto miny2 = std::min(l2.a.y, l2.b.y);
Point<T> p1(std::max(minx1, minx2), std::max(miny1, miny2));
Point<T> p2(std::min(maxx1, maxx2), std::min(maxy1, maxy2));
if (!pointOnSegment(p1, l1)) {
std::swap(p1.y, p2.y);
}
if (p1 == p2) {
return {3, p1, p2};
} else {
return {2, p1, p2};
}
}
}
auto cp1 = cross(l2.a - l1.a, l2.b - l1.a);
auto cp2 = cross(l2.a - l1.b, l2.b - l1.b);
auto cp3 = cross(l1.a - l2.a, l1.b - l2.a);
auto cp4 = cross(l1.a - l2.b, l1.b - l2.b);
if ((cp1 > 0 && cp2 > 0) || (cp1 < 0 && cp2 < 0) || (cp3 > 0 && cp4 > 0) || (cp3 < 0 && cp4 < 0)) {
return {0, Point<T>(), Point<T>()};
}
Point p = lineIntersection(l1, l2);
if (cp1 != 0 && cp2 != 0 && cp3 != 0 && cp4 != 0) {
return {1, p, p};
} else {
return {3, p, p};
}
}
template<class T>//直线和线段
//2 规范相交
//1 非规范相交(部分重叠,端点相交)
//0 不相交
int linecrossseg(const Line<T> &l1,const Line<T> &l2){
int d1 = sgn(cross((l1.b - l1.a),(l2.a-l1.a)));
int d2 = sgn(cross((l1.b - l1.a),(l2.b - l1.a)));
if ((d1 ^ d2) == -2) return 2;
return (d1 == 0 || d2 == 0);
}
template<class T> // 两条直线
//0 平行
//1 重合
//2 相交
int linecrossline(const Line<T> &l1,const Line<T> &l2){
double a1 = (l2.b - l2.a) ^ (l1.a - l2.a);
double a2 = (l2.b - l2.a) ^ (l1.b - l2.a);
return Point((l1.a.x * a2 - l1.b.x * a1) / (a2 - a1), (l1.a.y * a2 - l1.b.y * a1) / (a2 - a1
));
}
template<class T>//两条线段的最短距离
double distanceSS(const Line<T> &l1, const Line<T> &l2) {
if (std::get<0>(segmentIntersection(l1, l2)) != 0) {
return 0.0;
}
return std::min({distancePS(l1.a, l2), distancePS(l1.b, l2), distancePS(l2.a, l1), distancePS(l2.b, l1)});
}
template<class T>//线段是否在多边形内部
bool segmentInPolygon(const Line<T> &l, const std::vector<Point<T>> &p) {
int n = p.size();
if (!pointInPolygon(l.a, p)) {
return false;
}
if (!pointInPolygon(l.b, p)) {
return false;
}
for (int i = 0; i < n; i++) {
auto u = p[i];
auto v = p[(i + 1) % n];
auto w = p[(i + 2) % n];
auto [t, p1, p2] = segmentIntersection(l, Line(u, v));
if (t == 1) {
return false;
}
if (t == 0) {
continue;
}
if (t == 2) {
if (pointOnSegment(v, l) && v != l.a && v != l.b) {
if (cross(v - u, w - v) > 0) {
return false;
}
}
} else {
if (p1 != u && p1 != v) {
if (pointOnLineLeft(l.a, Line(v, u))
|| pointOnLineLeft(l.b, Line(v, u))) {
return false;
}
} else if (p1 == v) {
if (l.a == v) {
if (pointOnLineLeft(u, l)) {
if (pointOnLineLeft(w, l)
&& pointOnLineLeft(w, Line(u, v))) {
return false;
}
} else {
if (pointOnLineLeft(w, l)
|| pointOnLineLeft(w, Line(u, v))) {
return false;
}
}
} else if (l.b == v) {
if (pointOnLineLeft(u, Line(l.b, l.a))) {
if (pointOnLineLeft(w, Line(l.b, l.a))
&& pointOnLineLeft(w, Line(u, v))) {
return false;
}
} else {
if (pointOnLineLeft(w, Line(l.b, l.a))
|| pointOnLineLeft(w, Line(u, v))) {
return false;
}
}
} else {
if (pointOnLineLeft(u, l)) {
if (pointOnLineLeft(w, Line(l.b, l.a))
|| pointOnLineLeft(w, Line(u, v))) {
return false;
}
} else {
if (pointOnLineLeft(w, l)
|| pointOnLineLeft(w, Line(u, v))) {
return false;
}
}
}
}
}
}
return true;
}
template<class T>//构建上下两个凸包
auto getpart(std::vector<Point<T>> p) {
std::sort(p.begin(), p.bnd(),
[&](auto a, auto b) {
return a.x < b.x || (a.x == b.x && a.y < b.y);
});
std::vector<Point<T>> hi, lo;
for (auto p : p) {
while (hi.size() > 1 && cross(hi.back() - hi[hi.size() - 2], p - hi.back()) >= 0) {
hi.pop_back();
}
while (!hi.empty() && hi.back().x == p.x) {
hi.pop_back();
}
hi.push_back(p);
while (lo.size() > 1 && cross(lo.back() - lo[lo.size() - 2], p - lo.back()) <= 0) {
lo.pop_back();
}
if (lo.empty() || lo.back().x < p.x) {
lo.push_back(p);
}
}
return std::make_pair(hi, lo);
}
template<class T>//完整凸包
vector<Point<T>> convexhull(vector<Point<T>> a) {
int n = a.size();
sort(a.begin(), a.end(), [&](auto a, auto b) {
if (a.x !=b.x) {
return a.x < b.x;
}
return a.y < b.y;
});
vector<Point<T>> b;
for (int i = 0; i < n; i++) {
while (b.size() > 1 && sgn(cross(b[(int) b.size() - 1] - b[(int) b.size() - 2], a[i] - b[(int) b.size() - 2])) <= 0) {
b.pop_back();
}
b.push_back(a[i]);
}
int k = b.size();
for (int i = n - 2; i >= 0; i--) {
while (b.size() > k && sgn(cross(b[(int) b.size() - 1] - b[(int) b.size() - 2], a[i] - b[(int) b.size() - 2])) <= 0) {
b.pop_back();
}
b.push_back(a[i]);
}
b.pop_back();
return b;
}
template<class T> //包含边上点凸包
vector<Point<T>> Andrew(vector<Point<T>> a) // Andrew 算法求凸包 包括边上的点
{
int n = a.size();
sort(a.begin(), a.end(), [&](auto a, auto b) {
if (a.x !=b.x) {
return a.x < b.x;
}
return a.y < b.y;
});
sort(a, a + n);
vector<Point<T>> b;
for (int i = 0; i < n; i++)
{
while (b.size() > 1 && cross(b[b.size() - 2], b[b.size() - 1], a[i]) < 0) b.pop_back();
b.push_back(a[i]);
}
int k = b.size();
for (int i = n - 2; i >= 0; i--)
{
while (b.size()> k && cross(b[b.size() - 2], b[b.size() - 1], a[i]) < 0) b.pop_back();
b.push_back(a[i]);
}
if (n > 1) b.pop_back();
return b;
}
// 圆
template<class T>
struct Circle{
Point<T> p;
T r;
Circle() {}
Circle(Point<T> _p, T _r) {
p = _p;
r = _r;
}
bool operator == (Circle v) {
return (p == v.p) && sgn(r - v.r) == 0;
}
bool operator < (Circle v)const {
return ((p < v.p) || ((p == v.p) && sgn(r - v.r) < 0));
}
//面积
T area() {
return pi * r * r;
}
//周长
T circumference() {
return 2.0 * pi * r;
}
};
template<class T>//三点共圆求圆
Circle<T> circlecenter(Point<T> a,Point<T> b,Point<T> c){
long double a1 = b.x - a.x, b1 = b.y - a.y, c1 = (a1 * a1 + b1 * b1) / 2.0;
long double a2 = c.x - a.x, b2 = c.y - a.y, c2 = (a2 * a2 + b2 * b2) / 2.0;
long double d = a1 * b2 - a2 * b1;
Point<T> p=Point<T>(a.x + (c1 * b2 - c2 * b1) / d, a.y + (a1 * c2 - a2 * c1) / d);
T r=distance(a,p);
return {p,r};
}
template<class T> //三角形的外接圆
Circle<T> Circumcircle(Point<T> a, Point<T> b, Point<T> c) {
Line<T> u = Line<T>((a + b) / 2, ((a + b) / 2) + ((b - a).rotleft()));
Line<T> v = Line<T>((b + c) / 2, ((b + c) / 2) + ((c - b).rotleft()));
Point<T> p = lineIntersection(u,v);
T r = distance(a,p);
return {p,r};
}
template<class T>// 三角形内切圆
Circle<T> InscribedCircle(Point<T> A, Point<T> B, Point<T> C){
T a = distance(B,C);
T b = distance(A,C);
T c = distance(A,B);
Line AB(A, B);
Point<T> p = (A * a + B * b + C * c) / (a + b + c);
T r = distancePL(AB,p);
return {p,r};
}
template<class T>//点和圆的关系
//0 圆外
//1 圆上
//2 圆内
int relation(Circle<T> &l,Point<T> &b) {
T dst = distance(b,l.p);
if (sgn(dst - l.r) < 0) return 2;
else if (sgn(dst - l.r) == 0) return 1;
return 0;
}
template<class T> //线段和圆的关系
//比较的是圆心到线段的距离和半径的关系
int relationseg(Circle<T> &a,Line<T> &v) {
T dst = istancePS(a.p,v);
if (sgn(dst - a.r) < 0) return 2;
else if (sgn(dst - a.r) == 0) return 1;
return 0;
}
template<class T> //直线和圆的关系
//比较的是圆心到直线的距离和半径的关系
int relationline(Circle<T> &a,Line<T> &v) {
T dst = distancePL(a.p,v);
if (sgn(dst - a.r) < 0) return 2;
else if (sgn(dst - a.r) == 0) return 1;
return 0;
}
template<class T> //两圆的关系
//5 相离
//4 外切
//3 相交
//2 内切
//1 内含
//需要 distance
int relationcircle(Circle<T> &v,Circle<T> &a) {
T d = distance(a.p,v.p);
if (sgn(d - a.r - v.r) > 0) return 5;
if (sgn(d - a.r - v.r) == 0) return 4;
T l = fabs(a.r - v.r);
if (sgn(d - a.r - v.r) < 0 && sgn(d - l) > 0) return 3;
if (sgn(d - l) == 0) return 2;
if (sgn(d - l) < 0) return 1;
}
template<class T> //求两个圆的交点,返回 0 表示没有交点,返回 1 是一个交点,2 是两个交点
//需要 relationcircle
int pointcrosscircle(Circle<T> &a,Circle<T> &v, Point<T>& p1, Point<T>& p2) {
int rel = relationcircle(a,v);
if (rel == 1 || rel == 5)return 0;
T d = distance(a.p,v.p);
T l = (d * d + a.r * a.r - v.r * v.r) / (2 * d);
T h = sqrt(a.r * a.r - l * l);
Point<T> tmp = a.p + (v.p - a.p).trunc(l);
p1 = tmp + ((v.p - a.p).rotleft().trunc(h));
p2 = tmp + ((v.p - a.p).rotright().trunc(h));
if (rel == 2 || rel == 4)
return 1;
return 2;
}
template<class T>//求直线和圆的交点,返回交点个数
int pointcrossline(Circle<T> &b,Line<T> &v, Point<T>& p1, Point<T>& p2) {
if (!relationline(b,v)) return 0;
Point<T> a = projection(b.p,v);
T d = distancePL(b.p,v);
d = sqrt(b.r * b.r - d * d);
if (sgn(d) == 0) {
p1 = a;
p2 = a;
return 1;
}
p1 = a + (v.b - v.s).trunc(d);
p2 = a - (v.e - v.s).trunc(d);
return 2;
}
template<class T> //得到过 a,b 两点,半径为 r1 的两个圆
int gercircle(Point<T> &a, Point<T> &b, T r1, Circle<T>& c1, Circle<T>& c2) {
Circle<T> x(a, r1), y(b, r1);
int t = pointcrosscircle(x,y, c1.p, c2.p);
if (!t) return 0;
c1.r = c2.r = r1;
return t;
}
template<class T>//得到与直线 u 相切,过点 q, 半径为 r1 的圆 返回个数,以及每个圆
int getcircle(Line<T> &u, Point<T> &q, T r1, Circle<T> &c1, Circle<T> &c2) {
T dis = distancePL(q,u);
if (sgn(dis - r1 * 2) > 0) return 0;
if (sgn(dis) == 0) {
c1.p = q + ((u.b - u.a).rotleft().trunc(r1));
c2.p = q + ((u.b - u.a).rotright().trunc(r1));
c1.r = c2.r = r1;
return 2;
}
Line<T> u1 = Line<T>((u.a + (u.b - u.a).rotleft().trunc(r1)), (u.b + (u.b - u.a).rotleft().trunc(r1)));
Line<T> u2 = Line<T>((u.a + (u.b - u.a).rotright().trunc(r1)), (u.b + (u.b - u.a).rotright().trunc(r1)));
Circle<T> cc = Circle(q, r1);
Point<T> p1, p2;
if (!pointcrossline(cc,u1, p1, p2))
pointcrossline(cc,u2, p1, p2);
c1 = Circle(p1, r1);
if (p1 == p2) {
c2 = c1;
return 1;
}
c2 = Circle(p2, r1);
return 2;
}
template<class T> //同时与直线 u,v 相切,半径为 r1 的圆
int getcircle(Line<T> &u, Line<T> &v, T r1, Circle<T>& c1, Circle<T>& c2, Circle<T>& c3, Circle<T>& c4) {
if (parallel(u,v))return 0;//两直线平行
Line<T> u1 = Line<T>(u.s + (u.e - u.s).rotleft().trunc(r1), u.e + (u.e - u.s).rotleft().trunc(r1));
Line<T> u2 = Line<T>(u.s + (u.e - u.s).rotright().trunc(r1), u.e + (u.e - u.s).rotright().trunc(r1));
Line<T> v1 = Line<T>(v.s + (v.e - v.s).rotleft().trunc(r1), v.e + (v.e - v.s).rotleft().trunc(r1));
Line<T> v2 = Line<T>(v.s + (v.e - v.s).rotright().trunc(r1), v.e + (v.e - v.s).rotright().trunc(r1));
c1.r = c2.r = c3.r = c4.r = r1;
c1.p = lineIntersection(u1,v1);
c2.p = lineIntersection(u1,v2);
c3.p = lineIntersection(u2,v1);
c4.p = lineIntersection(u2,v2);
return 4;
}
template<class T>//同时与不相交圆 cx,cy 相切,半径为 r1 的圆
int getcircle(Circle<T> &cx, Circle<T> &cy, T r1, Circle<T>& c1, Circle<T>& c2) {
Circle<T> x(cx.p, r1 + cx.r), y(cy.p, r1 + cy.r);
int t =pointcrosscircle(x,y, c1.p, c2.p);
if (!t) return 0;
c1.r = c2.r = r1;
return t;
}
template<class T> //过一点作圆的切线 (先判断点和圆的关系)
int tangentline(Circle<T> &a,Point<T> &q, Line<T> &u, Line<T> &v) {
int x = relation(a,q);
if (x == 2) return 0;
if (x == 1) {
u = Line<T>(q, q + (q - a.p).rotleft());
v = u;
return 1;
}
T d = distance(a.p,q);
T l = a.r * a.r / d;
T h = sqrt(a.r * a.r - l * l);
u = Line<T>(q, a.p + ((q - a.p).trunc(l) + (q - a.p).rotleft().trunc(h)));
v = Line<T>(q, a.p + ((q - a.p).trunc(l) + (q - a.p).rotright().trunc(h)));
return 2;
}
template<class T> //求两圆相交的面积
T areacircle(Circle<T> &d,Circle<T> &v)
{
int rel = relationcircle(d,v);
if (rel >= 4) return 0.0;
if (rel <= 2) return min(d.area(), v.area());
T a = distance(d.p,v.p), b = a.r, c = v.r;
T cta1 = acos((a * a + b * b - c * c) / 2 / (a * b)),
cta2 = acos((a * a + c * c - b * b) / 2 / (a * c));
T s1 = d.r * d.r * cta1 - d.r * d.r * sin(cta1) * (a * a + b * b - c * c) / 2 / (a * b);
T s2 = v.r * v.r * cta2 - v.r * v.r * sin(cta2) * (a * a + c * c - b * b) / 2 / (a * c);
return s1 + s2;
}
template<class T> //求圆和三角形 pab 的相交面积
T areatriangle(Circle<T> &v,Point<T> &a, Point<T> &b) {
if (sgn(cross((v.p - a),(v.p - b))) == 0) return 0.0;
Point<T> q[5];
int len = 0;
q[len++] = a;
Line<T> l(a, b);
Point<T> p1, p2;
if (pointcrossline(v,l, q[1], q[2]) == 2) {
if (sgn(dot((a - q[1]),(b - q[1]))) < 0) q[len++] = q[1];
if (sgn(dot((a - q[2]),(b - q[2]))) < 0) q[len++] = q[2];
}
q[len++] = b;
if (len == 4 && sgn(dot((q[0] - q[1]),(q[2] - q[1]))) > 0) swap(q[1], q[2]);
T res = 0;
for (int i = 0; i < len - 1; i++) {
if (relation(v,q[i]) == 0 || relation(v,q[i + 1]) == 0) {
T arg = rad(v.p,q[i], q[i + 1]);
res += v.r * v.r * arg / 2.0;
}
else {
res += fabs(cross((q[i] - v.p),(q[i + 1] - v.p))) / 2.0;
}
}
return res;
}
template<class T> //两圆公切线
//返回值为公切线条数,-1表示无数条公切线
//线段起点都是大圆上切点,终点都是小圆v上切点(除了存在公切点时)
int tangentcircle(Circle<T> &a,Circle<T> &v, Line<T> l[4])
{
int t = relationcircle(a,v);
if (a.r < v.r)//使当前圆为半径大者
return tangentcircle(v,a,l);
if (t == 5)//相离
{
//特判半径相同情况
if (sgn(a.r - v.r) == 0)
{
l[0].a = a.p + (v.p - a.p).rotleft().trunc(a.r);
l[0].b = l[0].a + v.p - a.p;
l[1].a = a.p + (v.p - a.p).rotright().trunc(a.r);
l[1].b = l[1].a + v.p - a.p;
Point<T> q = (a.p + v.p) / 2;
Line<T> t1, t2;
tangentline(a,q, t1, t2);
l[2].a = t1.b;
l[3].a = t2.b;
tangentline(v,q, t1, t2);
l[2].b = t1.b;
l[3].b = t2.b;
}
else
{
T d = distance(a.p,v.p);
Point<T> q = v.p + (v.p - a.p).trunc(v.r * d / (a.r - v.r));
Line<T> t1, t2;
tangentline(a,q, t1, t2);
l[0].a = t1.b;
l[1].a = t2.b;
tangentline(v,q, t1, t2);
l[0].b = t1.b;
l[1].b = t2.b;
q = a.p + (v.p - a.p).trunc(a.r * d / (a.r + v.r));
tangentline(a,q, t1, t2);
l[2].a = t1.b;
l[3].a = t2.b;
tangentline(v,q, t1, t2);
l[2].b = t1.b;
l[3].b = t2.b;
}
}
else if (t == 4)//外切
{
//特判半径相同情况
if (sgn(a.r - v.r) == 0)
{
l[0].a = a.p + (v.p - a.p).rotleft().trunc(a.r);
l[0].b = l[0].a + v.p - a.p;
l[1].a = a.p + (v.p - a.p).rotright().trunc(a.r);
l[1].b = l[1].a + v.p - a.p;
Point<T> q = (a.p + v.p) / 2;
Line<T> t1, t2;
tangentline(a,q, t1, t2);
l[2] = t1;
}
else
{
T d = distance(a.p,v.p);
Point<T> q = v.p + (v.p - a.p).trunc(v.r * d / (a.r - v.r));
Line<T> t1, t2;
tangentline(a,q, t1, t2);
l[0].a = t1.b;
l[1].a = t2.b;
tangentline(v,q, t1, t2);
l[0].b = t1.b;
l[1].b = t2.b;
q = a.p + (v.p - a.p).trunc(a.r);
tangentline(a,q, t1, t2);
l[2] = t1;
}
}
else if (t == 3)//相交
{
//特判半径相同情况
if (sgn(a.r - v.r) == 0)
{
l[0].a = a.p + (v.p - a.p).rotleft().trunc(a.r);
l[0].b = l[0].a + v.p - a.p;
l[1].a = a.p + (v.p - a.p).rotright().trunc(a.r);
l[1].b = l[1].a + v.p - a.p;
}
else
{
T d = distance(a.p,v.p);
Point<T> q = v.p + (v.p - a.p).trunc(v.r * d / (a.r - v.r));
Line<T> t1, t2;
tangentline(a,q, t1, t2);
l[0].a = t1.b;
l[1].a = t2.b;
tangentline(v,q, t1, t2);
l[0].b = t1.b;
l[1].b = t2.b;
}
}
else if (t == 2)//内切
{
//特判半径相同情况
if (sgn(a.r - v.r) == 0)
return -1;//无数条公切线
else
{
Point<T> q = a.p + (v.p - a.p).trunc(a.r);
Line<T> t1, t2;
tangentline(a,q, t1, t2);
l[0] = t1;
}
}
//内含的情况直接返回0
return t - 1;
}
template<class T>// 极角排序
struct ACcmp {
Point<T> o;
ACcmp(const Point<T> &p0) {
o = p0;
}
// 获取象限 (0, 1, 2, 3)
int Quadrant(Point<T> p) { return sgn(p.y < 0) << 1 | sgn(p.x < 0) ^ sgn(p.y < 0); }
// 比较函数
bool operator()(const Point<T> &aa, const Point<T> &bb) {
Point<T> p = aa - o, q = bb - o;
int x = Quadrant(p), y = Quadrant(q);
if (x == y) {
if (sgn(cross(p,q)) == 0) return p.len2() < q.len2();
return sgn(cross(p,q)) > 0;
}
return x < y;
}
};
template<class T>//求最左下角的点 返回点和数组序号
Point<T> mipoint(vector<Point<T>> a,int& t) { //求最左下角的点 返回点和数组序号
Point<T> mi(inf, inf);
int n=a.size();
for (int i = 0; i < n; i++)
{
if (dcmp(mi.y, a[i].y) > 0)mi.y = a[i].y, t = i;
if (dcmp(mi.y, a[i].y) == 0)
if (dcmp(mi.x, a[i].x) > 0) mi.x = a[i].x, t = i;
}
return mi;
}
template<class T> //判断是不是凸的
bool isconvex(vector<Point<T>> a) {
bool s[3];
memset(s, false, sizeof(s));
int n=a.size();
for (int i = 0; i < n; i++) {
int j = (i + 1) % n;
int k = (j + 1) % n;
s[sgn(cross((a[j] - a[i]) , (a[k] - a[i]))) + 1] = true;
if (s[0] && s[2]) return false;
}
return true;
}
template<class T>// 直线切割多边形
vector<Point<T>> convexcut(Line<T> u,vector<Point<T>> a) {
vector<Point<T>> b;
int n=a.size();
for (int i = 0; i < n; i++) {
int d1 = sgn((u.b - u.a) ^ (a[i] - u.a));
int d2 = sgn((u.b - u.a) ^ (a[(i + 1) % n] - u.a));
if (d1 >= 0) b.push_back(a[i]);
if (d1 * d2 < 0) b.push_back = lineIntersection(u,Line(a[i], a[(i + 1) % n]));
}
return b;
}
template<class T>// 周长
T getcircumference(vector<Point<T>> a) {
T sum = 0;
int n=a.size();
for (int i = 0; i < n; i++) {
sum += distance(a[i],a[(i + 1) % n]);
}
return sum;
}
template<class T>//面积
T getarea(vector<Point<T>> a) {
T sum = 0;
int n=a.size();
for (int i = 0; i < n; i++) {
sum += (cross(a[i] , a[(i + 1) % n]));
}
return fabs(sum) / 2;
}
template<class T> //得到方向
// 1 表示逆时针,0 表示顺时针
bool getdir(vector<Point<T>> a) {
T sum = 0;
int n=a.size();
for (int i = 0; i < n; i++)
sum += cross(a[i] , a[(i + 1) % n]);
if (sgn(sum) > 0) return 1;
return 0;
}
template<class T> //多边形和圆交的面积
double areacircle(Circle<T> &c,vector<Point<T>> &a) {
T ans = 0;
int n=a.size();
for (int i = 0; i < n; i++) {
int j = (i + 1) % n;
if (sgn(cross((a[j] - c.p) , (a[i] - c.p))) >= 0)
ans += areatriangle(c,a[i], a[j]);
else ans -= areatriangle(c,a[i], a[j]);
}
return fabs(ans);
}
template<class T> //多边形重心
Point<T> getbarycentre(vector<Point<T>> &a) {
Point ret(0, 0);
T area = 0;
int n=a.size();
for (int i = 1; i < n - 1; i++) {
double tmp = cross((a[i] - a[0]),(a[i + 1] - a[0]));
if (sgn(tmp) == 0)continue;
area += tmp;
ret.x += (a[0].x + a[i].x + a[i + 1].x) / 3 * tmp;
ret.y += (a[0].y + a[i].y + a[i + 1].y) / 3 * tmp;
}
if (sgn(area)) ret = ret / area;
return ret;
}
template<class T> //多边形和圆关系
// 2 圆完全在多边形内
// 1 圆在多边形里面,碰到了多边形边界
// 0 其它
int relationcircle(vector<Point<T>> &a,Circle<T> &c) {
int x = 2;
int n=a.size();
if (pointInPolygon(c.p,a) != 1) return 0;//圆心不在内部
for (int i = 0; i < n; i++) {
Line<T> l(a[i],a[(i+1)%n]);
if (relationseg(c,l) == 2) return 0;
if (relationseg(c,l) == 1) x = 1;
}
return x;
}
template<class T>// 旋转卡壳,求凸包直径
T Rotating_calipers(vector<Point<T>> &a)
{
if(a.size()==2) return distance(a[0],a[1]);
T ans = 0;
int n=a.size();
int op = 0;
for (int i = 0; i < n; i++)
{
while (cross(a[i], a[i + 1], a[op]) <= cross(a[i], a[i + 1], a[op + 1]))
op = (op + 1) % n;
ans = max(ans, max((a[i] - a[op]).len(), (a[i + 1] - a[op]).len()));
}
return ans;
}
// 平面最近点对部分
template<class T>
static bool cmpx(Point<T> &a, Point<T> &b) {
return a.x < b.x || (a.x == b.x && a.y < b.y);
}
template<class T>
static bool cmpy(Point<T> &a, Point<T> &b) {
return a.y < b.y || (a.y == b.y && a.x < b.x);
}
template<class T> //平面最近点对 必须先对p使用上面的cmp排序后使用 l r为p下标范围
T Closest_Pair(vector<Point<T>> p,int left, int right) {
Point<T> tmpt[maxp];
T d = inf;
if (left == right) return d;
if (left + 1 == right) return distance(p[left],p[right]);
int mid = (left + right) / 2;
T d1 = Closest_Pair(p,left, mid);
T d2 = Closest_Pair(p,mid + 1, right);
d = min(d1, d2);
int cnt = 0;
for (int i = left; i <= right; i++) {
if (fabs(p[mid].x - p[i].x) <= d)
tmpt[cnt++] = p[i];
}
sort(tmpt, tmpt + cnt, cmpy);
for (int i = 0; i < cnt; i++) {
for (int j = i + 1; j < cnt && tmpt[j].y - tmpt[i].y < d; j++)
d = min(d, distance(tmpt[i],tmpt[j]));
}
return d;
}
Point<double> O(0,0);
void solve(){
int n,k;
cin>>n>>k;
vector<Point<double>> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a.begin(),a.end(),ACcmp(O));
if(k==n){
cout<<setprecision(10)<<fixed<<2.0*pi<<"\n";
return;
}
double mx=0;
for(int i=0;i<n;i++){
int x=i;
int y=(i+k)%n;
double x1=rad(a[x]);
double y1=rad(a[y]);
if(x1<0) x1+=2*pi;
if(y1<0) y1+=2*pi;
if(x+k<n) mx=max(mx,y1-x1);
else mx=max(mx,2*pi+y1-x1);
//cout<<y<<" "<<x<<" "<<x1<<" "<<y1<<"\n";
}
cout<<fixed<<setprecision(10)<<mx<<"\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin>>t;
while(t--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4268kb
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.2831853072 1.5707963268 5.4977871438 3.1415926546 3.1415926536
result:
ok 5 numbers
Test #2:
score: 0
Accepted
time: 45ms
memory: 4200kb
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.6929914975 2.5748634361 4.6527582673 2.7726331074 5.7427658069 4.8576989910 3.4198923126 2.8127999621 6.2831853072 6.2831853072 5.1172807667 6.1467827028 3.8420890235 2.3424967168 3.4633432080 6.2831853072 5.9614347528 3.3247034709 5.2627749281 5.6724593428 1.6738779353 1.1141908549 2.4087775518 6...
result:
ok 10000 numbers
Test #3:
score: 0
Accepted
time: 48ms
memory: 4264kb
input:
10000 19 7 -10 -6 -10 5 -3 0 -2 -5 -1 1 -1 6 0 3 0 7 1 9 3 -3 3 3 3 8 4 -1 5 8 6 -3 7 -5 7 4 8 10 9 -5 15 15 -9 -1 -8 6 -7 9 -6 -3 -4 -9 -1 -3 -1 8 1 -8 1 -7 3 -2 3 1 6 -9 7 -10 7 0 10 -9 10 3 -7 -1 -6 -2 -6 10 -5 2 -4 2 -3 -7 -2 -9 1 -3 3 4 7 7 15 4 -8 -8 -8 8 -7 0 -7 10 -6 -7 -5 6 -1 -3 -1 0 1 -2 ...
output:
3.9269908170 6.2831853072 3.3602615995 2.6779450446 3.7703889400 1.7625844688 3.8402524783 5.4977871438 2.0344439358 1.8157749899 4.3471875306 6.1412882526 5.1760365894 5.4655402613 5.7690391513 4.3662530168 5.9947557487 4.8922424802 4.1719694801 5.6776406436 5.9614347528 3.5067941034 4.5429759365 5...
result:
ok 10000 numbers
Test #4:
score: 0
Accepted
time: 46ms
memory: 4268kb
input:
10000 18 12 -10 -4 -10 7 -8 -10 -7 -4 -6 5 -6 7 -5 0 -2 -7 -1 2 -1 10 0 2 1 1 3 -2 5 3 5 5 6 -3 8 -3 9 -2 10 1 -10 -9 -7 -7 -5 2 -4 -7 -3 1 3 1 3 3 5 -4 9 2 9 6 11 2 -8 1 -8 6 -7 -2 -6 0 -5 0 -1 -9 2 -8 3 5 6 0 10 -2 10 6 20 9 -10 -6 -10 6 -9 -8 -7 5 -6 -4 -4 -8 -2 -10 -2 -3 -2 4 -1 1 2 -5 3 -2 5 -6...
output:
4.9097845402 1.9756881131 1.9868608325 3.9269908170 3.6977588837 6.2831853072 6.1412882526 6.1938713142 5.8053542522 6.2528915473 5.7288778110 3.0900918426 1.8925468812 5.6341897482 2.8966139905 6.2831853072 2.9147938055 6.1476575932 1.9513027039 5.5643553076 5.4977871438 3.0981417582 4.3906384260 3...
result:
ok 10000 numbers
Test #5:
score: 0
Accepted
time: 45ms
memory: 4240kb
input:
10000 19 7 -10 -1 -8 2 -7 -10 -6 6 -4 7 -3 -5 -3 1 -3 8 -2 4 -1 -7 0 -8 0 9 1 -10 2 1 2 3 3 5 6 -4 10 2 10 3 14 10 -8 2 -6 0 -5 -10 -5 10 -4 7 -3 -6 -2 -6 1 4 1 6 2 -1 3 -6 8 -4 9 -10 10 -1 12 8 -9 5 -7 2 -4 2 0 -2 0 5 1 6 3 2 4 9 5 5 7 -6 9 -9 9 2 19 12 -10 -10 -10 2 -9 -6 -8 2 -7 -5 -6 8 -4 1 -1 -...
output:
3.2393195609 5.2757052419 5.3003915839 5.3871299226 5.8883941875 4.1173193567 1.1383885512 1.5152978215 6.1476575932 6.1588303126 2.5748634361 5.9401613668 1.6085142793 4.6099451269 5.0711596507 4.2345579254 3.7905882126 4.0376480382 3.9160022483 1.0636978224 4.2809882538 5.8572556506 3.4078447027 5...
result:
ok 10000 numbers
Test #6:
score: 0
Accepted
time: 48ms
memory: 4236kb
input:
10000 11 10 -10 -1 -9 4 -9 10 -7 -7 -5 4 -4 -1 -2 -10 0 -7 0 5 3 3 3 5 12 12 -9 6 -9 8 -3 -2 -2 2 0 -4 1 0 2 -3 3 5 5 -2 7 -1 10 3 10 9 14 12 -10 0 -9 -3 -9 1 -9 10 -8 -1 -8 7 -6 -1 -1 -6 -1 2 1 -1 3 -7 4 9 9 -3 10 1 10 4 -9 -3 -7 -1 -6 -10 -3 -2 -3 7 2 -2 2 3 5 2 6 9 9 6 10 2 -9 -9 -9 6 -8 3 -5 -9 ...
output:
6.1378752965 6.2831853072 6.1180366298 3.2003484763 2.6537562149 6.2537820190 3.6052402626 3.5598169832 1.5091461562 5.9275494229 6.2587998980 2.6224465393 4.3938333033 5.4977871438 4.2487413714 5.4977871438 4.6292477485 3.5464844399 6.0048856482 1.1967518953 2.8854412710 6.2000440753 1.9237867146 5...
result:
ok 10000 numbers
Test #7:
score: 0
Accepted
time: 51ms
memory: 4244kb
input:
10000 14 1 -100 13 -96 -31 -82 -92 -77 -98 -50 1 -14 -57 -14 -31 -11 64 -8 75 9 68 25 100 54 -36 59 13 93 31 19 19 -76 -39 -60 95 -51 18 -39 11 -21 -46 -6 -94 -5 83 -3 -34 -3 72 0 -55 3 79 14 17 23 -88 32 37 50 70 61 -5 62 -43 84 -100 97 -50 13 7 -99 -63 -68 -87 -24 62 -20 -18 -2 -66 7 -49 13 -21 15...
output:
1.2713093975 6.2831853072 5.2225147207 6.0030657036 3.9258721355 5.5465289951 3.2103149237 3.0399300499 4.2275317818 3.0320196657 2.1912152338 3.0390080904 4.3313271506 6.2831853072 5.1100022651 2.9463140261 5.1760365894 5.6991835714 2.0611798651 6.2831853072 2.2278897855 6.1707748616 6.2831853072 6...
result:
ok 10000 numbers
Test #8:
score: 0
Accepted
time: 42ms
memory: 4248kb
input:
100 1413 755 -30 -30 -30 -28 -30 -27 -30 -26 -30 -21 -30 -12 -30 -10 -30 -8 -30 -5 -30 -1 -30 2 -30 4 -30 7 -30 9 -30 17 -30 19 -30 20 -30 23 -30 24 -30 30 -29 -29 -29 -23 -29 -15 -29 0 -29 4 -29 5 -29 9 -29 10 -29 11 -29 12 -29 14 -29 16 -29 17 -29 22 -29 27 -29 28 -28 -28 -28 -25 -28 -23 -28 -22 -...
output:
3.5891126287 2.9797552224 0.2837941092 2.0350277069 4.8879811423 1.0040671093 4.7457099763 5.3255963293 4.3102749647 5.6033836794 1.5798050921 4.3296454705 5.5472220968 1.4601391056 1.5310445514 2.8716749317 2.6325789669 3.1240505935 0.6805212247 5.4201656350 4.7789571442 2.4030352031 4.2799812048 4...
result:
ok 100 numbers
Test #9:
score: 0
Accepted
time: 48ms
memory: 4416kb
input:
20 9045 8319 -1000 -986 -1000 -683 -1000 -430 -1000 -292 -1000 53 -1000 667 -999 -855 -999 -350 -999 -174 -999 -51 -999 -43 -999 235 -999 465 -999 530 -998 -997 -998 -311 -998 21 -998 44 -998 182 -997 -313 -997 -195 -997 -13 -997 412 -997 425 -996 -542 -996 -348 -996 -126 -996 -59 -996 -40 -996 84 -...
output:
5.9115110039 3.7438685151 2.5384828583 2.1599673589 4.2950377096 4.7716744748 4.6824078126 5.0789843942 1.6008018214 3.3404025456 3.3687925283 2.1130160282 4.8553994101 4.3240010533 0.1078535611 0.1798211242 5.3766547607 4.4495660239 4.3944016652 2.9381848722
result:
ok 20 numbers
Test #10:
score: 0
Accepted
time: 57ms
memory: 5584kb
input:
1 166347 18723 -1000 -979 -1000 -975 -1000 -928 -1000 -914 -1000 -898 -1000 -889 -1000 -876 -1000 -873 -1000 -858 -1000 -840 -1000 -838 -1000 -801 -1000 -783 -1000 -744 -1000 -738 -1000 -733 -1000 -713 -1000 -712 -1000 -695 -1000 -689 -1000 -680 -1000 -675 -1000 -671 -1000 -646 -1000 -643 -1000 -608...
output:
0.8514491790
result:
ok found '0.8514492', expected '0.8514492', error '0.0000000'
Test #11:
score: 0
Accepted
time: 54ms
memory: 5640kb
input:
1 154903 84960 -1000 -979 -1000 -965 -1000 -956 -1000 -945 -1000 -920 -1000 -901 -1000 -878 -1000 -860 -1000 -858 -1000 -709 -1000 -693 -1000 -648 -1000 -619 -1000 -602 -1000 -579 -1000 -474 -1000 -473 -1000 -454 -1000 -443 -1000 -427 -1000 -407 -1000 -403 -1000 -384 -1000 -351 -1000 -279 -1000 -244...
output:
3.5389266854
result:
ok found '3.5389267', expected '3.5389267', error '0.0000000'
Test #12:
score: 0
Accepted
time: 55ms
memory: 5724kb
input:
1 158037 96343 -1000 -1000 -1000 -905 -1000 -881 -1000 -833 -1000 -804 -1000 -803 -1000 -782 -1000 -775 -1000 -765 -1000 -759 -1000 -756 -1000 -748 -1000 -722 -1000 -674 -1000 -669 -1000 -630 -1000 -610 -1000 -573 -1000 -443 -1000 -411 -1000 -409 -1000 -403 -1000 -388 -1000 -366 -1000 -349 -1000 -33...
output:
3.9720287783
result:
ok found '3.9720288', expected '3.9720288', error '0.0000000'
Test #13:
score: 0
Accepted
time: 60ms
memory: 4328kb
input:
10000 17 12 -853202371 684059854 -659446544 -924219854 -418025687 117998679 -399757126 -365708913 -331597239 -270896799 -204989763 869548983 -118492298 963842298 -77481232 672198731 45930201 -58234380 52605147 -900097542 78371985 940503934 235210685 595759114 391284089 234315077 416229789 -827244230...
output:
5.3985251100 5.3739078749 1.1735781729 1.5443652595 3.7782886494 3.5704715869 6.2829748588 5.0959252028 2.9875782466 2.3055665058 3.3907841642 5.7854732381 4.8109636123 0.9567574180 4.6294317310 4.7995080629 4.1702889056 5.7394776963 6.1210294480 3.5674682929 6.2280647244 6.2825675747 4.0146545584 0...
result:
ok 10000 numbers
Test #14:
score: 0
Accepted
time: 59ms
memory: 4272kb
input:
1000 133 108 -994106086 710243426 -991027749 -548437545 -983318226 -917527783 -943673956 -368162275 -935819096 616077188 -928022346 487569673 -924213856 -369318351 -914827619 426646545 -883935180 590882141 -870015071 -270471333 -834927107 -211343853 -829266515 354007200 -788041913 -60481736 -7822837...
output:
5.7428017921 1.9153642398 3.8043457981 1.7919162705 3.1695206706 6.0786462146 3.7860674595 3.6659690727 6.2265834530 5.9021521926 5.9443157093 0.7151676870 3.8315742530 1.2228457185 2.5984264669 5.5473289205 4.0791947428 0.7042209930 5.8578224268 0.6894854478 0.9379821529 1.4215226990 4.2713262792 3...
result:
ok 1000 numbers
Test #15:
score: 0
Accepted
time: 58ms
memory: 4376kb
input:
100 1367 924 -999416811 990355566 -997656126 346133696 -997071616 -657387469 -996176051 12622726 -995720693 334093112 -995478093 891631278 -994503890 341858449 -994297596 499383911 -993234202 533518057 -991636838 -4170504 -990563582 -407186200 -989454027 653116272 -989132124 -780605454 -988073521 -1...
output:
4.5051534906 2.7125589326 5.8396785810 6.0229771115 0.4616060431 0.9869912332 1.3219708488 1.9258417458 5.5086083533 4.6463553313 2.2876774102 2.1848725878 4.8094091918 0.4770789902 0.5563416050 1.0936191642 5.1827145536 3.1131846618 4.3802339550 2.7492592825 2.7917953347 6.2717333576 5.7538750453 2...
result:
ok 100 numbers
Test #16:
score: 0
Accepted
time: 62ms
memory: 4512kb
input:
10 13806 4955 -999669776 933068103 -999542354 721337508 -999499427 357140594 -999429088 -925180511 -999334813 -145726169 -999291694 -886327684 -999281647 811188099 -999145269 860687107 -998961821 -979442436 -998769313 446186367 -998591455 658309173 -998539751 -569480843 -998479467 279850955 -9984754...
output:
2.4170804680 6.1611922291 3.9600203768 3.9943617929 2.5515508362 0.5227238368 4.0978438279 6.2103826632 5.9817280293 0.7772236859
result:
ok 10 numbers
Test #17:
score: 0
Accepted
time: 48ms
memory: 5040kb
input:
1 112596 94970 -999980219 399324466 -999932413 952114487 -999894556 -951211102 -999891030 -996222974 -999864824 412806264 -999853190 -269700371 -999845814 -23906803 -999841507 -459154880 -999825178 716247149 -999761774 -154047106 -999729655 -171480333 -999709604 -666447277 -999704754 -22442485 -9996...
output:
5.4425938793
result:
ok found '5.4425939', expected '5.4425939', error '0.0000000'
Test #18:
score: 0
Accepted
time: 71ms
memory: 5828kb
input:
1 161568 13252 -999991243 -113889211 -999976572 -361096764 -999970140 -505012445 -999960654 600963873 -999959339 -269932510 -999956568 734634576 -999941447 716485764 -999940305 64397798 -999939982 746532931 -999939921 995002380 -999932747 185078659 -999927136 585216518 -999914684 898656539 -99990452...
output:
0.6424745907
result:
ok found '0.6424746', expected '0.6424746', error '0.0000000'
Test #19:
score: 0
Accepted
time: 79ms
memory: 6320kb
input:
1 186192 126483 -999998234 974001047 -999976292 -133179660 -999967957 112862981 -999957851 70030467 -999951528 743907713 -999931316 66002112 -999907988 888991267 -999905412 470798211 -999903986 -103943462 -999900422 255729004 -999898174 917068198 -999884392 -183592605 -999880179 -650076162 -99987469...
output:
4.4012456841
result:
ok found '4.4012457', expected '4.4012457', error '0.0000000'
Test #20:
score: 0
Accepted
time: 47ms
memory: 4256kb
input:
1000 133 9 -10 -839744900 -10 -620593257 -10 -322048342 -10 578093727 -10 898998949 -9 -833794004 -9 -704882916 -9 -570204575 -9 -506146571 -9 -109555290 -9 309734100 -9 396668416 -8 -928874025 -8 376566668 -8 596463598 -8 600491164 -8 894775141 -7 -281322833 -7 49984651 -7 154512939 -7 205573228 -7...
output:
3.1415925829 6.2831852482 3.1415926144 3.1415911741 6.2831852703 6.2831852953 3.1415926492 6.2831853037 3.1415926402 6.2831852507 6.2831852816 3.1415927592 3.1415926454 3.1415926238 3.1415926152 6.2831852733 3.1415926494 3.1415926537 3.1415926533 6.2831853047 6.2831852029 3.1415926592 3.1415926505 3...
result:
ok 1000 numbers
Test #21:
score: 0
Accepted
time: 44ms
memory: 4744kb
input:
5 23120 8224 -10 -999575056 -10 -997485895 -10 -995458183 -10 -986953157 -10 -985268102 -10 -983223383 -10 -980910524 -10 -980404283 -10 -973605147 -10 -972441960 -10 -972440422 -10 -969122114 -10 -965754004 -10 -964812113 -10 -964558462 -10 -963159275 -10 -962972564 -10 -962085557 -10 -961552443 -1...
output:
3.1415926424 3.1415926312 3.1415926068 3.1415926494 6.2831852722
result:
ok 5 numbers
Test #22:
score: 0
Accepted
time: 30ms
memory: 4700kb
input:
1 99995 60000 1 100001 1 100002 1 100003 1 100004 1 100005 1 100006 1 100007 1 100008 1 100009 1 100010 1 100011 1 100012 1 100013 1 100014 1 100015 1 100016 1 100017 1 100018 1 100019 1 100020 1 100021 1 100022 1 100023 1 100024 1 100025 1 100026 1 100027 1 100028 1 100029 1 100030 1 100031 1 10003...
output:
6.2831853069
result:
ok found '6.2831853', expected '6.2831853', error '0.0000000'
Extra Test:
score: 0
Extra Test Passed