- 绕钉子的长绳子
- 2016-09-07 19:22:51 @
float就好。
(语言: c)
3 条评论
-
twd2 LV 9 MOD @ 2016-09-10 12:08:56
-
2016-09-10 11:34:21@
实际上printf用%f既可以输出float也可输出double
-
2016-09-07 22:55:39@
可以啊为什么不行
- 1
可以啊为什么不行
###****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;
}
```
这就尴尬了。。。
这是为什么呢?。。。
评测结果
编译成功
测试数据 #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;
}
```
你的代码明明是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;
}
```
###****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;
}
```