XV Open Cup named after E.V. Pankratiev. GP of Siberia-Swimming

给出两个点,找到过这两个点的等角螺线,并求出中间的螺线长

$c = \frac{b}{a}$

$p = a \times c^{\frac{\theta}{angle}}$

对弧线积分

#include <bits/stdc++.h>
using namespace std;
long double eps = 1e-8;
struct Point {
    long double x, y;
    Point(long double _x = 0, long double _y = 0) {
        x = _x; y = _y;
    }
    Point operator - (const Point &b) {
        return Point(x - b.x, y - b.y);
    }
}a[4];
long double Dot(Point &a, Point b) {
    return a.x * b.x + a.y * b.y;
}
long double len(Point &a) {
    return sqrt(Dot(a, a));
}
int cmp(long double x) {
    if (fabs(x) < eps) return 0; return eps > 0? 1: -1;
}
int main() {
    for (int i = 1; i <= 3; ++ i) cin >> a[i].x >> a[i].y;
    a[1] = a[1] - a[3];
    a[2] = a[2] - a[3];
    long double tmp = Dot(a[1], a[2]);
    long double len1 = len(a[1]), len2 = len(a[2]);
    if (cmp(tmp - len1 * len2) == 0) {
        long double ans = fabs(len1 - len2);
        cout << fixed << setprecision(12) << ans << ‘\n‘;
        return 0;
    }
    auto sqr = [&](long double x) -> long double {
        return x * x;
    };
    long double ang = acos(tmp / len1 / len2);
    long double ans = ang * len1;
    if (cmp(len1 - len2)) {
        long double C = len2 / len1;
        ans = (C - 1) / log(C) * ans;
        ans = ans * sqrt(1 + sqr(log(C) / ang));
    }
    cout << fixed << setprecision(12) << ans << ‘\n‘;
}

原文地址:https://www.cnblogs.com/tempestT/p/10673163.html

时间: 2024-10-29 00:57:50

XV Open Cup named after E.V. Pankratiev. GP of Siberia-Swimming的相关文章

XV Open Cup named after E.V. Pankratiev. GP of Tatarstan

A. Survival Route 留坑. B. Dispersed parentheses $f[i][j][k]$表示长度为$i$,未匹配的左括号数为$j$,最多的未匹配左括号数为$k$的方案数.时间复杂度$O(n^3)$. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; const int P=1000000009; const int N=310; int n,m

XVI Open Cup named after E.V. Pankratiev. GP of Siberia

A. Passage 枚举两个点,看看删掉之后剩下的图是否是二分图. #include <bits/stdc++.h> using namespace std ; const int MAXN = 205 ; vector < int > G[MAXN] ; int vis[MAXN] , col[MAXN] ; int n ; int dfs ( int u ) { for ( int i = 0 ; i < G[u].size () ; ++ i ) { int v =

XV Open Cup named after E.V. Pankratiev Stage 6, Grand Prix of Japan Problem J. Hyperrectangle

题目大意: 给出一个$d$维矩形,第i维的范围是$[0, l_i]$. 求满足$x_1 + x_2 + ...x_d \leq s$ 的点构成的单纯形体积. $d, l_i \leq 300$ 题解: watashi学长的blog传送门. 给出了求$a_1x_1 + a_2x_2 + ...a_dx_d \leq b $的通用做法.答案就是一个神奇的式子$\frac{1}{n!} * \sum_{I \subseteq S}{(-1)^{|I|}}*max\{0, b - \sum_{i \in

XVI Open Cup named after E.V. Pankratiev. GP of Eurasia

A. Nanoassembly 首先用叉积判断是否在指定向量右侧,然后解出法线与给定直线的交点,再关于交点对称即可. #include<bits/stdc++.h> using namespace std; const int Maxn=300020; typedef long long LL; typedef pair<int,int>pi; struct P{ double x,y; P(){x=y=0;} P(double _x,double _y){x=_x,y=_y;}

XVI Open Cup named after E.V. Pankratiev. GP of SPB

A. Bubbles 枚举两个点,求出垂直平分线与$x$轴的交点,答案=交点数+1. 时间复杂度$O(n^2\log n)$. #include<cstdio> #include<algorithm> #include<cmath> using namespace std; const double eps=1e-9; int sgn(double x){ if(x<-eps)return -1; if(x>eps)return 1; return 0; }

XVI Open Cup named after E.V. Pankratiev. GP of Ekaterinburg.

贼惨 130/186 B Black Widow 简单题 #include <bits/stdc++.h> const long long mod = 1e9+7; const double ex = 1e-10; #define inf 0x3f3f3f3f using namespace std; map <int,int> M; int a[1010]; int b[100010]; int main() { int N; scanf("%d",&

XVII Open Cup named after E.V. Pankratiev. GP of SPb

A. Array Factory 将下标按前缀和排序,然后双指针,维护最大的右边界即可. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; const int N=200010; int n,i,j,anslen,ansl,ansr,mr,q[N]; ll a[N],lim; inline bool cmp(int x,int y){return a[x]<a[y];

XVII Open Cup named after E.V. Pankratiev. GP of Two Capitals

A. Artifact Guarding 选出的守卫需要满足$\max(a+b)\leq \sum a$,从小到大枚举每个值作为$\max(a+b)$,在权值线段树上找到最大的若干个$a$即可. 时间复杂度$O(n\log n)$. #include<cstdio> #include<algorithm> #include<set> #include<map> using namespace std; typedef long long ll; const

XIII Open Cup named after E.V. Pankratiev. GP of Asia and South Caucasus

A. RPG 首先计算出每个技能对于每个属性值的可行区间,若区间为空则不合法. 枚举两个技能,以及每个属性值,根据区间的关系可以得到哪个必须要在另一个之前学,连边看看是否有环即可. 时间复杂度$O(n^2m)$. #include<stdio.h> #include<algorithm> #include<math.h> #include<string.h> #include<string> #include<vector> #inc