求解……555……

#include<iostream>
#include<cmath>
float x[101],y[101],r;
using namespace std;
int main()
{
int n;
cin>>n>>r;
for(int i=0;i<n;i++)
cin>>x[i]>>y[i];
x[n+1]=x[0];
y[n+1]=y[0];

float total=0;
for(int i=0;i<n;i++){
total+=sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
}
total+=3.14*r*2;
cout<<total;
return 0;
}

10 条评论

  • @ 2016-07-28 19:54:08

    AC了,PI要精确到小数点后7位……

  • @ 2016-07-28 19:51:22

    只差一个点,没AC

  • @ 2016-07-28 19:50:59
    #include<iostream>
    #include<cmath>
    #include<cstdio>
    float x[101],y[101],r;
    using namespace std;
    int main()
    {
      int n;
      cin>>n>>r;
      for(int i=0;i<n;i++) cin>>x[i]>>y[i];
      x[n]=x[0];
      y[n]=y[0];
      float total=0;
      for(int i=0;i<n;i++){
      total+=sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
      }
      total+=3.14*r*2;
      printf("%.2f",total);
      return 0;
    }
    
  • @ 2016-07-28 19:49:16

    谢了,我发给你的东西你收到没?

  • @ 2016-07-27 16:09:09

    全AC了
    ```c++
    评测结果
    编译成功

    测试数据 #0: Accepted, time = 15 ms, mem = 556 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 552 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 552 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 556 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 556 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 556 KiB, score = 10
    Accepted, time = 15 ms, mem = 556 KiB, score = 60
    代码
    #include<iostream>
    #include<cmath>
    #include<cstdio>
    float x[101],y[101],r;
    using namespace std;
    int main()
    {
    int n;
    cin>>n>>r;
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    x[n]=x[0];
    y[n]=y[0];
    float total=0;
    for(int i=0;i<n;i++){
    total+=sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
    }
    total+=3.1415926*r*2;
    printf("%.2f",total);
    return 0;
    }

  • @ 2016-07-27 16:07:38

    因为你数组下标使用0~n-1
    所以
    x[n+1]=x[0];
    y[n+1]=y[0];
    要改成
    x[n]=x[0];
    y[n]=y[0];

  • @ 2016-07-27 12:33:14

    只AC三个点

  • @ 2016-07-27 12:27:52
    c++
    #include<iostream>
    #include<cmath>
    #include<cstdio>
    float x[101],y[101],r;
    using namespace std;
    int main()
    {
      int n;
      cin>>n>>r;
      for(int i=0;i<n;i++) cin>>x[i]>>y[i];
      x[n+1]=x[0];
      y[n+1]=y[0];
      float total=0;
      for(int i=0;i<n;i++){
      total+=sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
      }
      total+=3.14*r*2;
      printf("%.2f",total);
      return 0;
    }
    
  • @ 2016-07-26 16:42:17
    #include <cstdio>
    #include <cmath>
    using namespace std;
    int main() {
      int n;
      float a[101][3],ans = 0,r;
      scanf("%d %f\n",&n,&r);
      for (int i = 1;i <= n;i++)
        scanf("%f %f",&a[i][1],&a[i][2]);
      for(int i = 1;i < n;i++)
        ans += sqrt((a[i][1]-a[i+1][1])*(a[i][1]-a[i+1][1])+(a[i][2]-a[i+1][2])*(a[i][2]-a[i+1][2]));
      ans += sqrt((a[n][1]-a[1][1])*(a[n][1]-a[1][1])+(a[n][2]-a[1][2])*(a[n][2]-a[1][2]));
      printf("%.2f",ans+r*2*3.1415926);
      return 0;
    }
    
    • @ 2016-07-28 19:53:14
      #include<iostream>
      #include<cmath>
      #include<cstdio>
      float x[101],y[101],r;
      using namespace std;
      int main()
      {
        int n;
        cin>>n>>r;
        for(int i=0;i<n;i++) cin>>x[i]>>y[i];
        x[n]=x[0];
        y[n]=y[0];
        float total=0;
        for(int i=0;i<n;i++){
        total+=sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
        }
        total+=3.1415926*r*2;
        printf("%.2f",total);
        return 0;
      }
      
  • @ 2016-07-26 16:39:41

    一个数,绳子的长度,**精确到小数点后2位**。

  • 1

信息

ID
1007
难度
5
分类
模拟 点击显示
标签
(无)
递交数
12262
已通过
4337
通过率
35%
被复制
29
上传者