ZOJ 1394 Polar Explorer

Polar Explorer

Time Limit: 2 Seconds       Memory Limit: 65536 KB

Introduction

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.

However, you have recently received a distress call from an alien ship which has crash-landed somewhere on the surface of your planet. Unfortunately, you designed your own equipment, and the only information it will give you is an angle (measured from the center of the planet) separating you from the crash site.

Using this information along with how much gasoline is available for your planet-rover (which gets a measley 5 miles per gallon), you have to determine if you can possibly get to the crash site and back without running out of fuel.



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.

A single data set has 3 components: 

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

End line - A single line, "END". 

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

START
1 100 0
END
START
10 0 1
END
START
100 50 90
END
START
100 50 270
END
ENDOFINPUT


Sample Output

YES 100
NO 0
NO 250
NO 250


题意:X代表星球半径,Y代表汽油总量,Z代表角度,计算经过这样一段路程,汽油够不够用

注意:是来回的路程!

代码:

#include <stdio.h>
#include <string.h>
#define PI 3.14159




int main()
{
    char str1[]="ENDOFINPUT";
    char str[100];
    int X,Y,Z;
    float n;
    
    while(strcmp(gets(str),str1)!=0){
        scanf("%d%d%d",&X,&Y,&Z);
        getchar();
        gets(str);
        if(Z>180)
            Z=360-Z;
        n=(Z*1.0/360)*2*PI*X;
        if(2*n<=5*Y)
            printf("YES %d\n",(int)(5*Y-2*n)/5);
        else
            printf("NO %d\n",5*Y);
    }
    return 0;


}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值