2778:Ride to School-poj
2778:Ride to School
- 总时间限制:
- 1000ms
- 内存限制:
- 65536kB
- 描述
- Many graduate students of Peking University are living in Wanliu Campus, which is 4.5 kilometers from the main campus – Yanyuan. Students in Wanliu have to either take a bus or ride a bike to go to school. Due to the bad traffic in Beijing, many students choose to ride a bike.
We may assume that all the students except "Charley" ride from Wanliu to Yanyuan at a fixed speed. Charley is a student with a different riding habit – he always tries to follow another rider to avoid riding alone. When Charley gets to the gate of Wanliu, he will look for someone who is setting off to Yanyuan. If he finds someone, he will follow that rider, or if not, he will wait for someone to follow. On the way from Wanliu to Yanyuan, at any time if a faster student surpassed Charley, he will leave the rider he is following and speed up to follow the faster one.
We assume the time that Charley gets to the gate of Wanliu is zero. Given the set off time and speed of the other students, your task is to give the time when Charley arrives at Yanyuan.
- 输入
- There are several test cases. The first line of each case is N (1 <= N <= 10000) representing the number of riders (excluding Charley). N = 0 ends the input. The following N lines are information of N different riders, in such format:
Vi [TAB] Ti
Vi is a positive integer <= 40, indicating the speed of the i-th rider (kph, kilometers per hour). Ti is the set off time of the i-th rider, which is an integer and counted in seconds. In any case it is assured that there always exists a nonnegative Ti.
- 输出
- Output one line for each case: the arrival time of Charley. Round up (ceiling) the value when dealing with a fraction.
- 样例输入
-
4
20 0
25 -155
27 190
30 240
2
21 0
22 34
0 - 样例输出
-
780
771
代码:#include<iostream>
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
int main()
{
int n;
int v,t;
while((cin>>n)&&(n!=))
{
double time;
double min = 0x7fffffff;
for(int i=;i<=n;i++)
{
cin>>v>>t;
if(t < )
continue;
time=t+(4.5/double(v))*;//计算每个同学的时间
if(time<min)//取时间最短的那个
{
min=time;
}
}
cout<<ceil(min)<<endl;//ceil向上取
} return ;
}
2778:Ride to School-poj的更多相关文章
- 考研路茫茫——单词情结 HDU - 2243 AC自动机 && 矩阵快速幂
背单词,始终是复习英语的重要环节.在荒废了3年大学生涯后,Lele也终于要开始背单词了. 一天,Lele在某本单词书上看到了一个根据词根来背单词的方法.比如"ab",放在单词前一般 ...
- poj 2778 DNA Sequence ac自动机+矩阵快速幂
链接:http://poj.org/problem?id=2778 题意:给定不超过10串,每串长度不超过10的灾难基因:问在之后给定的长度不超过2e9的基因长度中不包含灾难基因的基因有多少中? DN ...
- POJ 2778 DNA Sequence(AC自动机+矩阵快速幂)
题目链接:http://poj.org/problem?id=2778 题意:有m种DNA序列是有疾病的,问有多少种长度为n的DNA序列不包含任何一种有疾病的DNA序列.(仅含A,T,C,G四个字符) ...
- POJ 2778 AC自己主动机+矩阵幂 不错的题
http://poj.org/problem?id=2778 有空再又一次做下,对状态图的理解非常重要 题解: http://blog.csdn.net/morgan_xww/article/deta ...
- POJ 2778 DNA Sequence(AC自动机+矩阵)
[题目链接] http://poj.org/problem?id=2778 [题目大意] 给出一些字符串,求不包含这些字符串的长度为n的字符串的数量 [题解] 我们将所有串插入自动机计算match,对 ...
- poj 2778 AC自己主动机 + 矩阵高速幂
// poj 2778 AC自己主动机 + 矩阵高速幂 // // 题目链接: // // http://poj.org/problem?id=2778 // // 解题思路: // // 建立AC自 ...
- POJ 2778 (AC自动机+矩阵乘法)
POJ 2778 DNA Sequence Problem : 给m个只含有(A,G,C,T)的模式串(m <= 10, len <=10), 询问所有长度为n的只含有(A,G,C,T)的 ...
- POJ 2778:DNA Sequence(AC自动机构造矩阵)
http://poj.org/problem?id=2778 题意:有m个病毒DNA,问构造一个长度为n的不带病毒DNA的字符串可以有多少种. 思路:看到这题有点懵,想了挺久题解的思路. 使用AC自动 ...
- POJ 2778 DNA Sequence(AC自动机+矩阵加速)
DNA Sequence Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9899 Accepted: 3717 Desc ...
随机推荐
- web前端——10个妨碍进步的学习方式
1.前言 从事web前端的人很多,每个人的学习方式,学习习惯基本不会一模一样!关于web前端(或者直接互联网),大家都知道,是做到老,学到老的一个行业.之前写文章的时候,我说过很多学习的方式和建议.今 ...
- Python装饰器,json,pickle
装饰器 定义:本质是函数,装饰其它函数是为了给其添加新功能: 原则:1.不能修改被装饰的函数的源代码 2.不能修改被装饰的函数的调用方式 实现装饰器知识储备: 1.函数即变量: 2.高阶函数 3.嵌套 ...
- Tracker-store
升级后发现有个tracker-store占用cpu非常厉害,查了下,好像是GNOME 3使用 Documents 來整合 本机 以及 在线(Google / Twitter)账户的文件,这个功能会呼叫 ...
- Zookeeper 笔记-应用场景
应用场景:数据发布,订阅:分布式应用配置项:分布式计数器:统一命名服务:状态同步服务:集群管理:Master选举:分布式锁:定时任务争夺:分布式队列:分布式协调通知 特点:顺序一致性,原子性,单一视图 ...
- [Web开发(1)] MyEclipse/Eclipse 使用Tomcat部署Web/Maven项目经典错误
1.Tomcat启动报错:server tomcat start within 45 seconds 问题原因:由于eclipse默认Tomcat设置是启动时间为45s,所以在45s内没有启动成功就会 ...
- iOS之 LLDB调试常用命令
LLDB是LLVM下的调试器.Xcode从4.0开始编译器开始改用LLVM,相应的调试器也从gdb改为LLDB. 1. p 用于输出基本类型 2. po 用于输出Objective-C对象 3. ex ...
- django 实现同一个ip十分钟内只能注册一次
很多小伙伴都会有这样的问题,说一个ip地址十分钟内之内注册一次,用来防止用户来重复注册带来不必要的麻烦 逻辑: 取ip,在数据库找ip是否存在,存在判断当前时间和ip上次访问时间之差,小于600不能注 ...
- zookeeper启动后的注意事项
在各节点中运行zkServer.sh start后 1.首先看进程是否存在 QuorumPeerMain. 2.查看zookeeper的运行状态 zkServer.sh status,会出现一个lea ...
- VS2008生成DLL并使用
1.创建工程 2.在工程中添加类,创建.h和.cpp文件 //.h代码 /** 请注意此代码方法声明中的 __declspec(dllexport) 修饰符. 这些修饰符使 DLL 能够导出该方法以供 ...
- 2456: mode
2456: mode Time Limit: 1 Sec Memory Limit: 1 MBSubmit: 4798 Solved: 2009[Submit][Status][Discuss] ...