POJ 3672 Long Distance Racing (模拟)
模拟 poj long Distance
2023-09-11 14:17:18 时间
题意:给定一串字符,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; }
相关文章
- 计算机等级考试二级C语言模拟试卷(六)
- 【进阶之路】性能测试 Linux 环境下模拟延时和丢包实现
- 【BZOJ3502/2288】PA2012 Tanie linie/【POJ Challenge】生日礼物 堆+链表(模拟费用流)
- 【BZOJ3252】攻略 DFS序+线段树(模拟费用流)
- 新的人工智能在模拟战斗中击败人类专家
- Gym 101190H Hard Refactoring (模拟坑题)
- UVaLive 6832 Bit String Reordering (模拟)
- Gym 100851E Easy Problemset (水题,模拟)
- 【C语言】简单模拟用户登录场景
- 【蓝桥杯2021模拟赛】【动态规划】跳跃(超详解+原理分析)
- 作差模拟两数相除(29. 两数相除)
- 使用Python进行页面模拟登录的多种方法汇总
- 如何在 macOS 上使用 Verilog 模拟电气模型
- 使用原生JavaScript模拟getElementByClassName .
- php模拟请求curl和fsockopen形式
- 【java案例】:模拟物流快递系统程序设计
- 性能值得期待,AMD Ryzen 5/Ryzen 3处理器模拟测试