POJ 3672 Long Distance Racing (模拟)
题意:给定一串字符,u表示是上坡,d表示下坡,f表示平坦的,每个有不同的花费时间,问你从开始走,最远能走到。
析:直接模拟就好了,没什么可说的,就是记下时间时要记双倍的,因为要返回来的。
代码如下:
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
using namespace std ; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1000 + 5;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
int m, n;
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
int t, u, f, d;
while(scanf("%d %d %d %d %d", &m, &t, &u, &f, &d) == 5){
int ans = 0;
char s[5];
LL cnt = 0;
for(int i = 0; i < t; ++i){
scanf("%s", s);
if(s[0] == 'u' || s[0] == 'd') cnt += u + d;
else if(s[0] == 'f') cnt += f + f;
if(cnt <= m) ++ans;
}
printf("%d\n", ans);
}
return 0;
}
POJ 3672 Long Distance Racing (模拟)的更多相关文章
- poj 2689 Prime Distance(大区间素数)
题目链接:poj 2689 Prime Distance 题意: 给你一个很大的区间(区间差不超过100w),让你找出这个区间的相邻最大和最小的两对素数 题解: 正向去找这个区间的素数会超时,我们考虑 ...
- poj 1008:Maya Calendar(模拟题,玛雅日历转换)
Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64795 Accepted: 19978 D ...
- POJ 1027 The Same Game(模拟)
题目链接 题意 : 一个10×15的格子,有三种颜色的球,颜色相同且在同一片内的球叫做cluster(具体解释就是,两个球颜色相同且一个球可以通过上下左右到达另一个球,则这两个球属于同一个cluste ...
- poj 1696 Space Ant(模拟+叉积)
Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3840 Accepted: 2397 Descrip ...
- POJ 3414 Pots【bfs模拟倒水问题】
链接: http://poj.org/problem?id=3414 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22009#probl ...
- POJ 2689 - Prime Distance - [埃筛]
题目链接:http://poj.org/problem?id=2689 Time Limit: 1000MS Memory Limit: 65536K Description The branch o ...
- poj 2632 Crashing Robots(模拟)
链接:poj 2632 题意:在n*m的房间有num个机器,它们的坐标和方向已知,现给定一些指令及机器k运行的次数, L代表机器方向向左旋转90°,R代表机器方向向右旋转90°,F表示前进,每次前进一 ...
- poj 1028 Web Navigation(模拟)
题目链接:http://poj.org/problem? id=1028 Description Standard web browsers contain features to move back ...
- POJ 3087 Shuffle'm Up (模拟+map)
题目链接:http://poj.org/problem?id=3087 题目大意:已知两堆牌s1和s2的初始状态, 其牌数均为c,按给定规则能将他们相互交叉组合成一堆牌s12,再将s12的最底下的c块 ...
随机推荐
- tomcat发布web service教程
这几天一直在准备找工作,自学了关于web service的一些基本的内容,也遇到了不少问题.现在就把我自己学到的知识和大家分享一下,由于是初学,所以有什么错误的地方请大家帮忙指正,感激不尽~~!! 1 ...
- freemarker中判断对象是否为空
<#if xxx?exists> 或则 <#if xxx??>两个问号??最简单方便
- Apache Struts2 s2-020补丁安全绕过漏洞
CNVD-ID CNVD-2014-01552 发布时间 2014-03-11 危害级别 高 影响产品 Apache struts 2.0.0-2.3.16 BUGTRAQ ID 65999 CVE ...
- Error: "DEVELOPER_DIR" is not defined at ./symbolicatecrash line 53
项目问题解析“Error: "DEVELOPER_DIR" is not defined at ./symbolicatecrash line 53.”这个问题是最近调试app的时 ...
- MySQL操作备忘录
在mysql包中,mysqld是数据库服务器,mysql是客户端,mysqladmin则用于管理数据库服务器的信息,如用户密码等. 关于安装: 1.在d:/sftwr/mysql/bin目录下: my ...
- java/python中获取当前系统时间,并与字符串相互转换格式,或者转化成秒数,天数等整数
java转换成秒数 Date类有一个getTime()可以换回秒数,例如: public class DateToSecond { public static void main(String[] a ...
- 面试题 IQ
现在有一大块金条,它可以分为七小块金条.是这样子的,工人为你工作7天,每天都将获得一小块金条,你要做的就是发工资,切割大块金条的次数最多两次,你有什么方法让工人每天都获得一小块金条呢?
- 高性能Server---Reactor模型-----Socket
高性能Server---Reactor模型 原文地址:http://www.ivaneye.com/2016/07/23/iomodel.html 无处不在的C/S架构 在这个充斥着云的时代,我们 ...
- java jvm学习笔记十一(访问控制器)
欢迎装载请说明出处: http://blog.csdn.net/yfqnihao/article/details/8271665 这一节,我们要学习的是访问控制器,在阅读本节之前,如果没有前面几节的 ...
- 转载:ofstream和ifstream详细用法
ofstream是从内存到硬盘,ifstream是从硬盘到内存,其实所谓的流缓冲就是内存空间; 在C++中,有一个stream这个类,所有的I/O都以这个“流”类为基础的,包括我们要认识的文件I/O, ...