1 solutions

  • 0
    @ 2025-11-5 17:08:17

    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

    Information

    ID
    18197
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By