Total Submit: 1477 Accepted Submit: 400
You are a intrepid 2-dimensional explorer located at the northern polar reaches of a distant 2-dimensional planet. Unfortunately, you have been assigned to explore the most boring planet in the known universe (due primarily to your lack of social skills and aggressive body odor). Having a perfectly circular surface, your planet holds no surprises for a would-be explorer.

Input
Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets.
Start line - A single line, "START".
Input line - A single line, "X Y Z", where:
X : (1 <= X <= 100) is the radius of your planet in integer miles
Y : (0 <= Y <= 100) is the amount of gasoline in your planet-rover in integer gallons
Z : (0 <= Z <= 360) is an angle separating you from the crash site in integer degrees
Following the final data set will be a single line, "ENDOFINPUT".
Take note of the following:
The circumference of a circle in terms of its radius, r, is known to be 2πr
Assume that π = 3.14159
Output
For each data set, there will be exactly one line of output. If you have enough fuel to get to the crash site and back, the line will read, "YES X" where X is the amount of fuel you will have left expressed as an integer number of gallons (truncate any fractional gallons). If you do not have sufficient fuel, the line will read, "NO Y" where Y is the distance you can travel expressed as an integer number of miles.
Sample Input
1 100 0
END
START
10 0 1
END
START
100 50 90
END
START
100 50 270
END
ENDOFINPUT
Sample Output
NO 0
NO 250
NO 250
这道题,做了好久,,不是因为难,是因为烦!除了烦还是烦!输出格式,输入格式要注意就行了!汗一个,最后ac了,还是听爽的呵呵!!!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define pi 3.14159
int main()...{
char ch[11];
float x,z;
float y;
gets(ch);
while(strcmp(ch,"START")== 0)
...{
scanf("%f%f%f", &x,&y,&z);
if(z > 180.0)
z = 360.0 - z;
float d = 2.0 * pi * x;
float s = y * 5;
d = d * z / 180.0;
if(d > s )
printf("NO %d ", (int)s);
else printf("YES %d ", (int)((s - d)/5.0) );
getchar();
gets(ch);
gets(ch);
}
system("pause");
return 0;
}
本文介绍了一个编程问题,即在一个圆形星球上,利用有限的燃料储备驾驶行星漫游车前往坠毁的外星飞船并返回基地的挑战。文章提供了一段示例代码,详细解释了如何根据距离和可用燃料计算是否能够完成往返任务。

649

被折叠的 条评论
为什么被折叠?



