。。。double类型无法通过

float就好。

(语言: c)

3 条评论

  • @ 2016-09-10 11:34:21

    实际上printf用%f既可以输出float也可输出double

  • @ 2016-09-07 22:55:39

    可以啊为什么不行

    • @ 2016-09-07 23:32:28

      不知道啊,我用同样的程序,double的话就是WA,float的话就AC。。。

    • @ 2016-09-08 13:19:40

      ###****double AC****
      ```c++
      评测结果
      编译成功

      测试数据 #0: Accepted, time = 0 ms, mem = 504 KiB, score = 10
      测试数据 #1: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      测试数据 #2: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      测试数据 #3: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      测试数据 #4: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      测试数据 #5: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      Accepted, time = 0 ms, mem = 508 KiB, score = 60
      代码
      #include<cstdio>
      #include<cmath>
      using namespace std;
      int main()
      {
      int n;
      double a[101][3],ans=0,r;
      scanf("%d %lf\n",&n,&r);
      for(int i=1;i<=n;i++)
      scanf("%lf %lf",&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("%.2lf",ans+r*2*3.1415926);
      return 0;
      }
      ```

    • @ 2016-09-08 14:23:13

      这就尴尬了。。。
      这是为什么呢?。。。
      评测结果
      编译成功

      测试数据 #0: WrongAnswer, time = 0 ms, mem = 488 KiB, score = 0
      测试数据 #1: WrongAnswer, time = 0 ms, mem = 484 KiB, score = 0
      测试数据 #2: WrongAnswer, time = 0 ms, mem = 484 KiB, score = 0
      测试数据 #3: WrongAnswer, time = 0 ms, mem = 484 KiB, score = 0
      测试数据 #4: WrongAnswer, time = 0 ms, mem = 484 KiB, score = 0
      测试数据 #5: WrongAnswer, time = 0 ms, mem = 488 KiB, score = 0
      WrongAnswer, time = 0 ms, mem = 488 KiB, score = 0
      代码
      ```c
      #include <stdio.h>
      #include <stdlib.h>
      #include <string.h>
      #include <malloc.h>
      #include <math.h>
      #define pi 3.1415926
      int n;
      double r;
      double result;
      struct point
      {
      double x,y;
      }p0,p1,p2;
      int i;

      double dis(struct point p1, struct point p2)
      {
      double result;
      result = sqrt(pow(p1.x-p2.x,2) + pow(p1.y-p2.y,2));
      return result;
      }
      int main()
      {
      result=0.0;
      scanf("%d %lf",&n,&r);
      scanf("%lf %lf",&p0.x, &p0.y);
      p1=p0;
      for (i=1;i<n;i++)
      {
      scanf("%lf %lf",&p2.x,&p2.y);
      result+=dis(p1,p2);
      p1=p2;
      }
      result+=dis(p1,p0);
      result+=2*pi*r;
      printf("%.2lf",result);

      return 0;
      }
      ```

    • @ 2016-09-09 13:44:20

      你的代码明明是AC的
      评测结果
      编译成功

      测试数据 #0: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      测试数据 #1: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      测试数据 #2: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      测试数据 #3: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      测试数据 #4: Accepted, time = 0 ms, mem = 508 KiB, score = 10
      测试数据 #5: Accepted, time = 0 ms, mem = 504 KiB, score = 10
      Accepted, time = 0 ms, mem = 508 KiB, score = 60
      代码
      ```c
      #include <stdio.h>
      #include <stdlib.h>
      #include <string.h>
      #include <malloc.h>
      #include <math.h>
      #define pi 3.1415926
      int n;
      double r;
      double result;
      struct point
      {
      double x,y;
      }p0,p1,p2;
      int i;

      double dis(struct point p1, struct point p2)
      {
      double result;
      result = sqrt(pow(p1.x-p2.x,2) + pow(p1.y-p2.y,2));
      return result;
      }
      int main()
      {
      result=0.0;
      scanf("%d %lf",&n,&r);
      scanf("%lf %lf",&p0.x, &p0.y);
      p1=p0;
      for (i=1;i<n;i++)
      {
      scanf("%lf %lf",&p2.x,&p2.y);
      result+=dis(p1,p2);
      p1=p2;
      }
      result+=dis(p1,p0);
      result+=2*pi*r;
      printf("%.2lf",result);

      return 0;
      }
      ```

    • @ 2016-09-09 15:05:57

      你选择的编译语言是 C++
      我选择的编译语言是 C
      。。。
      我不知道为什么C++能过,C不能过。
      大神求破~

    • @ 2016-09-09 15:17:36

      ###****c语言double输入是%lf,输出是%f****
      ```c++
      记录信息
      评测状态 Accepted
      题目 P1007 绕钉子的长绳子
      递交时间 2016-09-09 15:16:07
      代码语言 C
      评测机 ShadowShore
      消耗时间 0 ms
      消耗内存 488 KiB
      评测时间 2016-09-09 15:16:07
      评测结果
      编译成功

      测试数据 #0: Accepted, time = 0 ms, mem = 484 KiB, score = 10
      测试数据 #1: Accepted, time = 0 ms, mem = 484 KiB, score = 10
      测试数据 #2: Accepted, time = 0 ms, mem = 484 KiB, score = 10
      测试数据 #3: Accepted, time = 0 ms, mem = 484 KiB, score = 10
      测试数据 #4: Accepted, time = 0 ms, mem = 484 KiB, score = 10
      测试数据 #5: Accepted, time = 0 ms, mem = 488 KiB, score = 10
      Accepted, time = 0 ms, mem = 488 KiB, score = 60
      代码
      #include <stdio.h>
      #include <stdlib.h>
      #include <string.h>
      #include <malloc.h>
      #include <math.h>
      #define pi 3.1415926
      int n;
      double r;
      double result;
      struct point
      {
      double x,y;
      }p0,p1,p2;
      int i;

      double dis(struct point p1, struct point p2)
      {
      double result;
      result = sqrt(pow(p1.x-p2.x,2) + pow(p1.y-p2.y,2));
      return result;
      }
      int main()
      {
      result=0.0;
      scanf("%d %lf",&n,&r);
      scanf("%lf %lf",&p0.x, &p0.y);
      p1=p0;
      for (i=1;i<n;i++)
      {
      scanf("%lf %lf",&p2.x,&p2.y);
      result+=dis(p1,p2);
      p1=p2;
      }
      result+=dis(p1,p0);
      result+=2*pi*r;
      printf("%.2f",result);

      return 0;
      }
      ```

    • @ 2016-09-09 20:05:34

      哦哦~ 学习了~ 谢谢~

  • 1

信息

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