2 条题解
-
1无影 (吴鹏飞) LV 10 @ 2022-07-30 15:46:20
感谢感谢
-
02020-01-23 16:02:47@
观察一下,发现,最终绳子的长度=一个圆周长度+圆心逆时针首尾相连得到的多边形周长。
/* */ #define method_1 #ifdef method_1 /* */ #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<set> #include<map> #include<queue> #include<stack> #include<vector> #include<cstring> #include<cstdlib> #include<iomanip> #include<ctime> #include<string> #include<bitset> #define D(x) cout<<#x<<" = "<<x<<" " #define E cout<<endl using namespace std; typedef long long ll; typedef pair<int,int>pii; const int maxn=100+5; const int INF=0x3f3f3f3f; const double pi=acos(-1.0); int n; double r; double ans=0.0; double x[maxn],y[maxn]; double dis(int i,int j){ return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])); } void solve(){ ans+=2*pi*r; for(int i=1;i<=n;i++){ scanf("%lf%lf",&x[i],&y[i]); if(i==1) continue; ans+=dis(i,i-1); } ans+=dis(n,1); } int main() { ios::sync_with_stdio(false); // freopen("绕钉子的长绳子.in","r",stdin); scanf("%d%lf",&n,&r); solve(); printf("%.2lf",ans); return 0; } #endif #ifdef method_2 /* */ #endif #ifdef method_3 /* */ #endif
- 1