题解 AT3849 【[ABC084C] Special Trains】
题目大意
总共有 \(N\) 个车站,每两个相邻的车站有单向的车.
从第 \(i\) 个站到第 \(i+1\) 个站 需要时间 \(C_i\) 分钟,且第一趟车在 \(S_i\)分钟时发(之后每隔 \(F_i\) 分钟发一辆车)。
并且 数据保证 \(F_i\) 能被 \(F_i\) 整除。
要你求出每以个点到 \(N\) 的最少时间。
思路
因为 \(N\) \(<\) \(500\),所以不用多考虑,可以直接暴力模拟。
只要枚举出每一个点到其他各个点所需要最少的的时间即可。
但是虽然是需要求出 \(1\)~\(N\) 到 \(N\) 的时间,但是事实上 \(N\) 到 \(N\) 的时间为 \(0\),无需考虑。
最后输出最少所需的时间(即算出数的和)即可。
核心代码
ans=max(ans,s[j]);
if(ans%f[j]!=0) ans=ans+f[j]-ans%f[j];/*此处指处于间隔的时间之内(即未发车)*/
ans+=c[j];/*加上所需时间*/
题解 AT3849 【[ABC084C] Special Trains】的更多相关文章
- AtCoder Beginner Contest 084 C - Special Trains
Special Trains Problem Statement A railroad running from west to east in Atcoder Kingdom is now comp ...
- 题解-hdu2866 Special Prime
Problem hdu-2866 题意:求区间\([2,L]\)有多少素数\(p\)满足\(n^3+pn^2=m^3\),其中\(n,m\)属于任意整数 Solution 原式等价于\(n^2(p+n ...
- CF1454A Special Permutation 题解
Content 给定一个整数 \(n\),请构造出一个长度为 \(n\) 的排列 \(\{a_i\}_{i=1}^n\),使得对于每个 \(a_i\),都有 \(a_i\neq i\). 我们称一个长 ...
- Codeforces Round #353 (Div. 2) ABCDE 题解 python
Problems # Name A Infinite Sequence standard input/output 1 s, 256 MB x3509 B Restoring P ...
- poj-3739. Special Squares(二维前缀和)
题目链接: I. Special Squares There are some points and lines parellel to x-axis or y-axis on the plane. ...
- Codeforces Round #249 (Div. 2) D. Special Grid 枚举
题目链接: http://codeforces.com/contest/435/problem/D D. Special Grid time limit per test:4 secondsmemor ...
- Project Euler 106:Special subset sums: meta-testing 特殊的子集和:元检验
Special subset sums: meta-testing Let S(A) represent the sum of elements in set A of size n. We shal ...
- HDU 5839 Special Tetrahedron (计算几何)
Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...
- Codeforces Round #325 (Div. 2) D. Phillip and Trains BFS
D. Phillip and Trains Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/ ...
随机推荐
- 计算机网络协议,UDP数据报的分析
一.UDP数据报的特点 1.基本特性 UDP是在IP数据报的基础上增加了复用和分用以及差错检测的功能 UDP的主要特点如下: UDP是无连接的:即发送数据之前不需要建立连接 UDP使用尽最大努力交付, ...
- idea运行gradle项目报错,找不到符号符号,方向xxxx类未知
报错: 解决:把build和run设置为idea
- django创建app
前几天,
- android学习笔记——计时器实现
根据android疯狂讲义来写写代码,在博客里面将这些写过的代码汇总一下.实现的功能很简单:就是一个简单的计时器,点击启动按钮会开始计时,当计时到20秒时会自动停止计时. 界面如下: 界面代码: &l ...
- TcxGrid
一.列的宽度为64时,其宽度会自动根据字段的长度调整,设置其他值即为固定值: 二.cell中显示按钮:选中某列,在properties中更改为ButtonEdit,点击子属性buttons添加butt ...
- Delphi Unicode转中文
function UniCode2GB(S : String):String;Var I: Integer;beginI := Length(S);while I >=4 do begintry ...
- jdbctemplate打印sql
在logback.xml里加入如下配置即可: <include resource="org/springframework/boot/logging/logback/base.xml& ...
- 【题解】POJ3041 Asteroids - 图论 - 二分图匹配
声明:本博客所有题解都参照了网络资料或其他博客,仅为博主想加深理解而写,如有疑问欢迎与博主讨论✧。٩(ˊᗜˋ)و✧*。 POJ3041 Asteroids 题目描述 假如你现在正处在一个 \(N*N\ ...
- kafka高吞吐量之消息压缩
背景 保证kafka高吞吐量的另外一大利器就是消息压缩.就像上图中的压缩饼干. 压缩即空间换时间,通过空间的压缩带来速度的提升,即通过少量的cpu消耗来减少磁盘和网络传输的io. 消息压缩模型 消息格 ...
- vue+element-ui中引入阿里播放器
1.在public文件下的index.html文件中插入以下代码: <link rel="stylesheet" href="https://g.alicdn.co ...