zoj 1394 Polar Explorer

本文介绍了一种算法,用于确定行星漫游者是否有足够的燃料往返于事故地点。通过输入漫游者的最大行驶里程、可用燃料量及所需行驶的角度等参数,算法能够计算出行驶距离并判断是否可以安全返回。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

 

 

注意题目所说的是来回车程,而且所给的角不一定就是车所走的路线对应的角。。还需判断若角度大于180度,则应该选择小于180的角走。。

#include<iostream>
#include<string.h>
using namespace std;
#define PI 3.14159 
int main()
{
	int r,y,o,v=5;
	char s[10];
	float l;
	while(cin>>s)
	{
		if(strcmp(s,"START")==NULL)
		{
			cin>>r>>y>>o>>s;
			if(o>180)o=360-o;
			l=o*1.0/360*2*PI*r;
			if(v*y>=2*l)cout<<"YES "<<(int)(v*y-2*l)/v<<endl;
			else
				cout<<"NO "<<v*y<<endl;	
		}
		else
			if(strcmp(s,"ENDOFINPUT")==NULL)break;

		
	}
	return 0;

	
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值