313 条题解

  • 0
    @ 2014-10-06 16:42:29

    #include<cstdio>
    #include<cmath>

    using namespace std;

    int main()
    {
    int N;
    double R,x[101],y[101];
    scanf("%d%lf",&N,&R);
    for(int i=1;i<=N;i++)
    scanf("%lf%lf",x+i,y+i);
    x[N+1]=x[1];
    y[N+1]=y[1];
    double ans=3.141592*R*2.0;
    for(int i=1;i<=N;i++)
    ans+=sqrt((x[i+1]-x[i])*(x[i+1]-x[i])+(y[i+1]-y[i])*(y[i+1]-y[i]));
    printf("%.2lf",ans);
    return 0;
    }

  • 0
    @ 2014-10-06 01:30:15

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    int main()
    {
    int N,n;
    float R,X2,Y2,X1,Y1,dis=0,sum=0,s1,s2;
    scanf("%d %f",&N,&R);
    if(N==1)
    {scanf("%f %f",&X2,&Y2);
    printf("%.2f",2*R*3.141);}
    else
    {scanf("%f %f",&X2,&Y2);
    s1=X2,s2=Y2;
    for(n=2;n<=N;n++)
    {X1=X2;Y1=Y2;
    scanf("%f %f",&X2,&Y2);
    dis=sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));
    sum=sum+dis;
    }
    printf("%.2f",sum+2*R*3.141+sqrt((s1-X2)*(s1-X2)+(s2-Y2)*(s2-Y2)));}

    return 0;
    }

  • 0
    @ 2014-09-01 19:26:53

    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    int main()
    {
    double pi=3.1415926,len=0,c,r;
    double x[10],y[10];
    int n,i;
    // freopen("in.in","r",stdin);
    // freopen("out.out","w",stdout);
    scanf("%d%lf",&n,&r);
    for(i=1;i<=n;i++)
    scanf("%lf%lf",&x[i],&y[i]);
    x[n+1]=x[1];
    y[n+1]=y[1];
    for(i=1;i<=n;i++)
    len+=sqrt(pow(x[i]-x[i+1],2)+pow(y[i]-y[i+1],2));
    c=r*pi*2;
    len+=c;
    printf("%.2lf",len);
    // fclose(stdin);
    //fclose(stdout);
    //system("pause");
    return 0;
    }

    为什么,这段代码回运行错误

  • 0
    @ 2014-08-05 16:45:35

    测试数据 #0: Accepted, time = 0 ms, mem = 248 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 248 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 244 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 248 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 248 KiB, score = 10
    测试数据 #5: Accepted, time = 15 ms, mem = 244 KiB, score = 10
    做水题加信心2333

    include <stdio.h>

    include <math.h>

    double q(double a,double b,double c,double d)
    {
    return sqrt((c-a)*(c-a)+(d-b)*(d-b));}
    int main()
    {
    int i,N,j;
    double a,b,c,d,r,s,k,l;
    const double pi = 4.0 * atan(1.0);
    scanf("%d%lf", &N,&r);
    s = 2 * pi * r;
    scanf("%lf%lf", &a, &b);
    for(i = 2;i <= N;i++)
    {
    if(i % 2 == 0) scanf("%lf%lf", &c, &d);
    else scanf("%lf%lf", &a, &b);
    s += q(a,b,c,d);
    if(i == 2) {k = a;l = b;}
    if(i == N) s += (i % 2 == 0) ? q(c,d,k,l) : q(a,b,k,l);}
    printf("%.2lf\n", s);
    }

  • 0
    @ 2014-08-04 09:40:32

    水………………

    记录信息
    评测状态 Accepted
    题目 P1007 绕钉子的长绳子
    递交时间 2014-08-04 09:39:04
    代码语言 C++
    评测机 VijosEx
    消耗时间 30 ms
    消耗内存 272 KiB
    评测时间 2014-08-04 09:39:09
    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 272 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 272 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 268 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 272 KiB, score = 10
    测试数据 #4: Accepted, time = 15 ms, mem = 272 KiB, score = 10
    测试数据 #5: Accepted, time = 15 ms, mem = 272 KiB, score = 10
    Accepted, time = 30 ms, mem = 272 KiB, score = 60

  • 0
    @ 2014-06-25 19:14:19

    #include <cstdio>
    #include <cmath>
    const double Pi = acos(-1.0);
    int main()
    { int n;
    double r;
    scanf("%d%lf", &n, &r);
    double x[n], y[n];
    for (int i = 0; i < n; i++)
    scanf("%lf%lf", &x[i], &y[i]);
    double ans = 2*Pi*r;
    for (int i = 0; i < n; i++)
    ans += sqrt((x[i]-x[(i+1)%n])*(x[i]-x[(i+1)%n])+(y[i]-y[(i+1)%n])*(y[i]-y[(i+1)%n]));
    printf("%.2lf\n", ans);
    return 0;
    }

  • 0
    @ 2014-03-01 09:54:11

    算法:
    题目已经说了是逆时针了, 所以只要s:=s+len(a[i].x,a[i].y,a[i-1].x,a[i-1].y);
    整个绳子绕在圆上的长度合起来是一个整圆

  • 0
    @ 2014-01-01 11:57:19

    Vijos 题解:http://hi.baidu.com/umule/item/2c997f8ed9600fdae596e017
    有疑问请留言 共同进步

  • 0
    @ 2013-12-03 11:29:12

    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #define PI 3.1415926
    #define REP( i, n ) for ( int i = 1; i <= n; i ++ )
    #define FOR( i, a, b ) for ( int i = a; i <= b; i ++ )
    #define DWN( i, a, b ) for ( int i = b; i >= a; i -- )
    #define RST( a, x ) memset ( a, x, sizeof ( a ) );
    #define ONLINE_JUDGE NULL

    using namespace std;
    double x[ 200 ], y[ 200 ], r, ans, t1, t2;
    int n;
    int main ()
    {

    #ifndef ONLINE_JUDGE
    freopen ( "P1000.in", "r", stdin );
    freopen ( "P1000.out", "w", stdout );
    #endif

    scanf ( "%d%lf", &n, &r );
    ans = r * 2 * PI;
    REP ( i, n )
    {
    scanf ( "%lf%lf", &x[ i ], &y[ i ] );
    if ( i > 1 ) t1 = x[ i ] - x[ i - 1 ], t2 = y[ i ] - y[ i - 1 ];
    ans += sqrt ( t1 * t1 + t2 * t2 );
    }
    t1 = x[ 1 ] - x[ n ], t2 = y[ 1 ] - y[ n ];
    ans += sqrt ( t1 * t1 + t2 * t2 );
    printf ( "%.2f\n", ans );
    return 0;
    }
    其实这题很弱菜……

  • 0
    @ 2013-10-08 15:26:29

    一上来把R定义成int了。。。神坑我三次WA。
    简单题,一上来还以为好难,用解析几何做了个算法,做了一半才发现自己傻X了,明明是凸多边形啊。。。线绕过的正好是一个圆啊。。。
    23行AC
    C++ Code:
    #include <iostream>
    #include <cmath>
    #include <iomanip>
    using namespace std;
    int main(){
    int n;
    double r;
    cin>>n;
    cin>>r;
    double p[101][2];
    double ans=0;
    for(int i=0;i<n;i++){
    cin>>p[i][0];
    cin>>p[i][1];
    }
    p[n][0]=p[0][0];
    p[n][1]=p[0][1];
    for(int i=1;i<=n;i++){
    ans+=hypot(fabs(p[i][0]-p[i-1][0]),fabs(p[i][1]-p[i-1][1]));
    }
    ans+=2.00000000*3.14159265358*r;
    cout<<setprecision(2)<<std::fixed<<ans;
    }

  • 0
    @ 2013-10-04 22:35:23

    不想说了 已经是凸包了 没看到 还写了个找凸包的....... 心都碎了

  • 0
    @ 2013-09-28 14:51:16

    一开始很烦啊,后来想通就好了

  • 0
    @ 2013-08-31 14:04:36
  • 0
    @ 2013-08-24 14:12:55

    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.

  • 0
    @ 2013-07-29 23:47:53

    水题。。注意pi,abs的返回值即可。纯C++版本。有钉子。

    Block Code

    #include<iostream>
    #include<cmath>
    #include<iomanip>
    #define PI 3.1415926
    using namespace std;

    int main()
    {
    short n;double r;
    cin>>n>>r;
    double ans=PI*2.0*r;
    double x,y,x1,y1,xs,ys;
    cin>>x>>y;
    xs=x;ys=y;
    for(int i=2;i<=n;++i)
    {
    cin>>x1>>y1;
    ans+=hypot(fabs(x1-x),fabs(y1-y));
    x=x1;y=y1;
    //cout<<ans<<"//";
    }
    ans+=hypot(fabs(xs-x),fabs(ys-y));
    cout<<setiosflag(ios::fixed)<<setprecision(2)<<ans;
    return 0;
    }

  • 0
    @ 2013-07-21 09:08:13

    表示不能容忍半径是实型、坑了后三个点……

  • 0
    @ 2013-02-16 10:10:22
    • @ 2015-10-26 18:18:55

      你是个沙茶吗?

  • 0
    @ 2012-11-29 23:26:40

    编译通过...

    ├ 测试数据 01:答案正确... (7ms, 200KB)

    ├ 测试数据 02:答案正确... (0ms, 200KB)

    ├ 测试数据 03:答案正确... (0ms, 200KB)

    ├ 测试数据 04:答案正确... (0ms, 200KB)

    ├ 测试数据 05:答案正确... (0ms, 200KB)

    ├ 测试数据 06:答案正确... (0ms, 200KB)

    ---|---|---|---|---|---|---|---|-

    Accepted / 100 / 7ms / 200KB

    P转C第二题

  • 0
    @ 2012-11-07 09:16:36

    注意不能用3.14哦~我就错了一组!!

信息

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