POJ 1922 解题报告

这道题其实是个智力题。

重点在于:

1.首先,不考虑提前出发的选手。除此之外,所有选手在0时刻都在起点。这些 “正常的”选手从出发开始,做的就是匀速运动,直到终点。所以答案就是这些选手中最先到达的时间。因为如果这样的选手如果超过了别人,第一个到达,那么在这个过程(超过别人)中,搭车人会搭他的车一同到达。

2.提前出发的选手可以直接忽略。因为,如果他们没有被超过,那么搭车人一直没机会遇到他们,如果被超过了,就更没有考虑的必要了。

除法的精度也是需要考虑的一个问题,4500 * 3.6 / speed能过而4500 / (speed / 3.6)不能过。前者有更高的精度。

thestoryofsnow1922Accepted156K16MSC++

/* 
ID: thestor1 
LANG: C++ 
TASK: poj1922 
*/
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <limits>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cassert>

using namespace std;

const int DIS = 4500;

int main()
{
	int n;
	while (scanf("%d", &n) == 1 && n)
	{
		int speed, starttime, mintime = -1;
		for (int i = 0; i < n; ++i)
		{
			scanf("%d%d", &speed, &starttime);
			if (starttime < 0)
			{
				continue;
			}

			int arrivaltime = ceil(starttime + DIS * 3.6 / speed);
			if (mintime < 0 || arrivaltime < mintime)
			{
				mintime = arrivaltime;
			}
		}
		printf("%d\n", mintime);
	}

	return 0;  
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值