313 条题解
-
01253490029 LV 8 @ 2016-01-08 08:05:28
python写的
import math
d = [float(i) for i in raw_input().split()]
total = 2*d[1]*math.pi
a = []
for i in range(int(d[0])):
b = [float(i) for i in raw_input().split()]
a.append(b)
a.append(a[0])
for i in range(int(d[0])):
total += math.sqrt((a[i][1]-a[i+1][1])**2 + (a[i][0]-a[i+1][0])**2)
print "%.2f" % total -
02015-12-03 16:57:12@
const pi=3.141592653;
var n,i:longint;
r,d,ans,x,y:real;
a,b:array[0..101] of real;
begin
readln(n,r);
for i:=1 to n do readln(a[i],b[i]);
a[n+1]:=a[1];//环处理
b[n+1]:=b[1];
ans:=2pir;
for i:=1 to n do
begin
x:=abs(a[i]-a[i+1]);
y:=abs(b[i]-b[i+1]);
d:=sqrt(xx+yy);
ans:=ans+d;
end;
writeln(ans:0:2);
end. -
02015-10-31 17:15:19@
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;int main()
{
int n;
double x1, y1, x2, y2;
double x, y;
double r;
double sum = 0.0;
cin >> n >> r;
cin >> x1 >> y1;
x = x1; y = y1;
for (int i = 1; i < n; i++)
{
cin >> x2 >> y2;
sum += sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
x = x2; y = y2;
}
sum += sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y));
sum += 3.14159265359 * 2 * r;
printf("%.2f\n", sum);
return 0;
} -
02015-10-27 21:28:30@
const pi=3.141592653;
var n,i:longint;
r,d,ans,x,y:real;
a,b:array[0..101] of real;
begin
readln(n,r);
for i:=1 to n do readln(a[i],b[i]);
a[n+1]:=a[1];//环处理
b[n+1]:=b[1];
ans:=2*pi*r;
for i:=1 to n do
begin
x:=abs(a[i]-a[i+1]);
y:=abs(b[i]-b[i+1]);
d:=sqrt(x*x+y*y);
ans:=ans+d;
end;
writeln(ans:0:2);
end. -
02015-09-26 13:47:17@
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;
int main (){
double x,y,ans=0,r,a,b,p,q,pi=acos (-1.0);
int n,i;
freopen ("rope.in","r",stdin);
freopen ("rope.out","w",stdout);
cin>>n>>r;
if (n==1){
printf ("%.2f",r*pi*2);
return 0;
}
cin>>x>>y;
p=a=x;
q=b=y;
for (i=1;i<n;i++){
cin>>x>>y;
ans+=sqrt ((a-x)*(a-x)+(b-y)*(b-y));
a=x;
b=y;
}
printf ("%.2f",ans+r*pi*2+sqrt ((p-x)*(p-x)+(q-y)*(q-y)));
return 0;
}记得千万不能加freopen
-
02015-09-15 01:46:38@
#include<stdio.h>
#include<stdlib.h>
#include<math.h>int main()
{
float x[100], y[100], length=0, totallength;
int N,R;
printf("请输入定点数和半径长度");
scanf("%d %d",&N,&R);
printf("请输入各点圆心所在位置");
for(int i=0;i<=N-1;i++)
{
scanf("%f %f",&x[i],&y[i]);
while(i>0)
{
length=length+ sqrt(( pow((x[i]-x[i-1]),2) + pow ((y[i]-y[i-1]),2)));
}
printf("2");
}
printf("the :");
length= length+ sqrt(((pow(x[N]-x[0],2)) +pow ((y[N]-y[0]),2)));
totallength=3.14*R*2+length;
printf("%.2f",totallength);
return 0;
} -
02015-09-03 11:55:43@
#include <iostream>
#include <cstdio>
#include <cmath>using namespace std;
#define pi 3.1415926535898;
int N;
double R;//必须写成double型,强制类型转换都不行
double x,y;
double xe1;
double ye1;
double xe2;
double ye2;
double k;
int i;int main()
{
cin>>N>>R;
cin>>x>>y;
xe1=x;
ye1=y;
for(i=2;i<=N;++i)
{
cin>>xe2>>ye2;
k+=sqrt(pow((xe2-xe1),2)+pow((ye2-ye1),2));
xe1=xe2;
ye1=ye2;
}
k+=sqrt(pow((x-xe1),2)+pow((y-ye1),2))+2.0*R*pi;
printf("%.2f",k);
return 0;
} -
02015-08-03 11:26:33@
#include <iostream>
#include <cmath>
#include <iomanip>
#define PI2 6.28318530717958
#define sqr(x) (pow(x,2))
#define len(z,w) (sqrt(sqr(z.x-w.x)+sqr(z.y-w.y)))
using namespace std;
typedef struct Coord { double x, y; } coord;
int main()
{
int n, i;
double R, sum;
cin >> n >> R;
coord dim[n];
sum = PI2*R;
cout << fixed << showpoint << setprecision(2);
for (i=0; i<n; i++) cin >> dim[i].x >> dim[i].y;
for (i=0; i<n; i++) sum += len(dim[i%n],dim[(i+1)%n]);
cout << sum << endl;
return 0;
} -
02015-07-31 10:54:45@
跪求大神指导,有两个wrong answer...
#include <stdio.h>
#include <malloc.h>
#include <math.h>int main()
{
int i, n;
float *x, *y;
float len = 0, r;scanf("%d %f", &n, &r);
x = (float *)malloc(sizeof(float)*n);
y = (float *)malloc(sizeof(float)*n);
for (i = 0; i < n; i++)
{
scanf("%f %f", &x[i], &y[i]);
}
//计算绳子长度
len = 3.14 * 2 * r;
for (i = 0; i < n-1; i++)
{
len += sqrt((x[i] - x[i + 1])*(x[i] - x[i + 1]) + (y[i] - y[i + 1])*(y[i] - y[i + 1]));
}
if(n>=3)
{
len += sqrt((x[0] - x[n-1])*(x[0] - x[n-1]) + (y[0] - y[n-1])*(y[0] - y[n-1]));
}
printf("%.2f\n", len);
return 0;
} -
02015-07-30 20:46:07@
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn=105;
const double pi=3.1415926;
int numn;
struct Point
{
double x;
double y;
}m[maxn];
int main()
{
double ans=0,r;
scanf("%d%lf",&numn,&r);
for(int i=1;i<=numn;i++)scanf("%lf%lf",&m[i].x,&m[i].y);
for(int i=2;i<=numn;i++)ans+=sqrt((m[i].x-m[i-1].x)*(m[i].x-m[i-1].x)+(m[i].y-m[i-1].y)*(m[i].y-m[i-1].y));
ans+=sqrt((m[numn].x-m[1].x)*(m[numn].x-m[1].x)+(m[numn].y-m[1].y)*(m[numn].y-m[1].y));
ans+=pi*2*r;
printf("%.2lf\n",ans);
return 0;
}
有点像小奥。。 -
02015-07-01 10:53:03@
var n,i:longint;
sum,r:real;
a,b:array[1..100] of real;
begin
read(n,r);
read(a[1],b[1]);
for i:=2 to n do
begin
read(a[i],b[i]);
sum:=sum+sqrt(sqr(abs(a[i]-a[i-1]))+sqr(abs(b[i]-b[i-1])));
end;
sum:=sum+sqrt(sqr(abs(a[n]-a[1]))+sqr(abs(b[n]-b[1])))+3.141592654*r*2;
writeln(sum:0:2);
end. -
02015-04-22 21:29:55@
var n,i:integer;
r,pi,c:real;
x,y:array[1..100]of real;
begin
readln(n,r);
pi:=3.14159;
readln(x[1],y[1]);
for i:=2 to n do
begin
readln(x[i],y[i]);
c:=c+sqrt(sqr(x[i]-x[i-1])+sqr(y[i]-y[i-1]));
end;
c:=c+sqrt(sqr(x[n]-x[1])+sqr(y[n]-y[1]))+2*r*pi;
writeln(c:0:2);
end. -
02015-04-12 20:37:48@
刚开始的时候没看清题目,写了个凸包。。
var
n,i,j:longint;
x,y,x0,y0,x1,y1:double;
res,r:double;
function dis(x,y,x1,y1:double):double;
begin
exit(sqrt(sqr(x-x1)+sqr(y-y1)));
end;
begin
readln(n,r);
readln(x,y);
x0:=x; y0:=y;
for i:=2 to n do
begin
readln(x1,y1);
res:=res+dis(x,y,x1,y1);
x:=x1; y:=y1;
end;
res:=res+dis(x,y,x0,y0);
res:=res+2*r*3.1415926;
writeln(res:0:2);
end. -
02015-03-29 20:20:04@
多灌In水gress,身体好……
iomanip
是 cout 的格式控制。本来用了rnd(k) (round(k*100)/100.0)
的宏,后来发现 cout 不会保留末尾的零(废话)。
```C++
#include <iostream>
#include <cmath>
#include <iomanip>
#define PI2 6.28318530717958
#define sqr(x) (pow(x,2))
#define len(z,w) (sqrt(sqr(z.x-w.x)+sqr(z.y-w.y)))
using namespace std;
typedef struct Coord { double x, y; } coord;int main(void) {
int n, i;
double R, sum;
cin >> n >> R;
coord dim[n]; // dimprpr www <- dimpurr..
sum = PI2*R;
cout << fixed << showpoint << setprecision(2);for (i=0; i<n; i++) cin >> dim[i].x >> dim[i].y; // 顺序不影响结果…
for (i=0; i<n; i++) sum += len(dim[i%n],dim[(i+1)%n]); // % 回来一圈cout << sum << endl;
return 0;
}
`` -
02015-02-13 21:50:19@
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main()
{
int n;
double r;
double length=0;
double pi=3.1415926535898;
cin>>n>>r;
double x[n];
double y[n];
for(int i=0;i<n;i++)
{
cin>>x[i];
cin>>y[i];
}
for(int j=0;j<n-1;j++)
{
length+=sqrt(pow((x[j+1]-x[j]),2)+pow((y[j+1]-y[j]),2));
}
length+=sqrt(pow((x[0]-x[n-1]),2)+pow((y[0]-y[n-1]),2));
length+=2*pi*r;
printf("%.2f",length);
return 0;
}
半径R是实数!!!!! -
02015-02-02 00:49:54@
#include "stdio.h"
#include "math.h"int n;
float r,a[100],b[100],length,temp;
int i,j,k;int main()
{
length=0.0;
scanf("%d%f",&n,&r);
for(i=0;i<n;i++) scanf("%f%f",&a[i],&b[i]);
length=2*r*3.1415926535898;
for(i=0;i<n-1;i++)
{
temp=sqrt(pow((a[i+1]-a[i]),2)+pow((b[i+1]-b[i]),2));
length=length+temp;
}length=length+sqrt(pow((a[n-1]-a[0]),2)+pow((b[n-1]-b[0]),2));
printf("%.2f",length);
return 0;
} -
02015-01-25 19:40:12@
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
using namespace std;
int main(){
int num;
cin >> num;
double r;
cin >> r;
double sum = 0;
vector<double> x(num);
vector<double> y(num);
for (int i = 0; i<num; i++)
cin >> x[i] >> y[i];
for (int i = 1; i<num; i++)
sum += sqrt((x[i] - x[i - 1])*(x[i] - x[i - 1]) + (y[i] - y[i - 1])*(y[i] - y[i - 1]));
sum += sqrt((x[num - 1] - x[0])*(x[num - 1] - x[0]) + (y[num - 1] - y[0])*(y[num - 1] - y[0]));
sum += 2 * 3.1415926*r;
cout<<setiosflags(ios::fixed)<<setprecision(2);
cout<<sum<<endl;
return 0;
} -
02014-12-30 15:43:42@
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
double x[100],y[100],r,ans,xi,yi;
int n,i;
cin>>n>>r;
for(i=0;i<n;i++)
cin>>x[i]>>y[i];
ans=0;
for(i=0;i<n-1;i++)
{
xi=x[i+1]-x[i];
yi=y[i+1]-y[i];
ans+=sqrt(xi*xi+yi*yi);
}
xi=x[n-1]-x[0];
yi=y[n-1]-y[0];
ans+=sqrt(xi*xi+yi*yi);
ans+=2*3.141592653589793*r;
cout<<setiosflags(ios::fixed)<<setprecision(2);
cout<<ans;
return 0;
} -
02014-11-25 00:59:50@
测试数据 #0: Accepted, time = 0 ms, mem = 1068 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 1072 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 1072 KiB, score = 10
测试数据 #3: Accepted, time = 15 ms, mem = 1068 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 1076 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 1072 KiB, score = 10
Accepted, time = 15 ms, mem = 1076 KiB, score = 60
代码
#include<iostream>
#include<cmath>using namespace std;
int main()
{
int n,i,temp,temp2;
double r,sum;
double zuobiao[32766][2];
cin>>n;
cin>>r;
sum=0.0;if(n==1)
{
sum=3.1415926535898 *2.0*r;temp2=sum*1000;
temp=sum*100;
sum=temp;
sum=sum/100;
if (temp2%10>4)
{
sum=sum+0.01;
}
cout<<sum;
return 0;
}for (i=0;i<=n-1;i++)
{
cin>>zuobiao[i][0];
cin>>zuobiao[i][1];
}for(i=0;i<=n-2;i++)
{
sum=sum+sqrt( pow( (zuobiao[i][0]-zuobiao[i+1][0]), 2 ) + pow( (zuobiao[i][1]-zuobiao[i+1][1]) ,2) );}
sum=sum+sqrt( pow( (zuobiao[0][0]-zuobiao[n-1][0]), 2 ) + pow( (zuobiao[0][1]-zuobiao[n-1][1]) ,2) );
sum=sum+3.1415926*2.0*r;
temp=sum*1000;
temp=sum*100;sum=temp;
sum=sum/100;
if (temp2%10>4)
{
sum=sum+0.01;
}cout<<sum<<endl;
return 0;
} -
02014-10-21 16:50:47@
var
--n,i:longint;
--a:array[1..100,1..2]of extended;
--long,x,r:extended;
begin
--read(n,r);
--for i:=1 to n do readln(a[i,1],a[i,2]);
--for i:=1 to n-1 do
--begin
---x:=sqrt(sqr(abs(a[i,1]-a[i+1,1]))+sqr(abs(a[i,2]-a[i+1,2])));
---long:=long+x;
--end;
--x:=sqrt(sqr(abs(a[n,1]-a[1,1]))+sqr(abs(a[n,2]-a[1,2])));
--long:=long+x+2*pi*r;
--write(long:0:2);
end.