1 条题解

  • 0
    @ 2024-12-24 10:06:06

    C++ :

    #include<iostream>
    #include<cstdlib>
    #include<cstdio>
    #include<cmath>
    #define pi 3.1415926539
    using namespace std;
    float juli(int,int);
    float a[110][4];
    int main()
    {
    	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
    
    	int n;
    	float s=0.0;
    	float r;
    	scanf("%d%f",&n,&r);
    	for(int i=1;i<=n;i++)
    		scanf("%f%f",&a[i][1],&a[i][2]);
        int z=1;
    	while(1)
    	{
             if(z==n)
    	    {
                s+=juli(n,1);
                break;
    		}
    	    s+=juli(z,z+1);
    	    z++;
    
        }
    	s+=2*pi*r;
    	printf("%.2f",s);
    	//system("pause");
    }
    float juli(int c,int d)
    {
    	float s;
        s=sqrt(pow(a[c][1]-a[d][1],2)+pow(a[c][2]-a[d][2],2));
    	return s;
    }
    
    
    • 1

    信息

    ID
    1916
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者