题解 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/ ...
随机推荐
- webpack配置示例
var webpack = require('webpack'); var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('commo ...
- Linux服务器 上传/下载 文档/目录
1.从服务器上下载文件 scp username@servername:/path/filename /var/www/local_dir(本地目录) 例如scp root@192.168.0.101 ...
- spark rdd元素println
1.spark api主要分两种:转换操作和行动操作.如果在转化操作中println spark打印了 我也看不到. val result = sqlContext.sql(sql) val resu ...
- Web开发与设计之Google兵器谱-Web开发与设计利器
Web开发与设计之Google兵器谱-Web开发与设计利器 博客分类: Java综合 WebGoogleAjaxChromeGWT 笔者是个Java爱好者也是用Java进行web开发的工作者.平时笔者 ...
- 子域名爆破工具:OneForALL
0x00 简介 OneForAll是一款功能强大的子域收集工具 0x01 下载地址 码云: https://gitee.com/shmilylty/OneForAll.git Github: http ...
- 手把手教Extjs-简单GridField示例讲解二
使用的Extjs版本为4.2,示例是官方的版本,对里面的语法进行一句一句的学习研究.可以方便他人,又可以提升自己的理解.里面存在的问题,后期会一步一步改进.也欢迎各位指出. /* Extjs具有很庞大 ...
- Spring Cloud 系列之 Gateway 服务网关(二)
本篇文章为系列文章,未读第一集的同学请猛戳这里:Spring Cloud 系列之 Gateway 服务网关(一) 本篇文章讲解 Gateway 网关的多种路由规则.动态路由规则(配合服务发现的路由规则 ...
- Windows环境下搭建Cocos2d-x3.2环境并配置android交叉编译环境
一.软件 1)VS2012(C++11特性在VS2012以上可以使用):传送门: 2)Cocos2d-x官网源码:传送门:http://cocos2d-x.org/download 3)JDK:传送门 ...
- jquary
1 定义: jquary是快速简介的Javascrīpt框架 2 分类 : 1) .js类 源代码的未压缩的可以进行更改的jquary 2) min ...
- 基于spring的安全管理框架-Spring Security
什么是spring security? spring security是基于spring的安全框架.它提供全面的安全性解决方案,同时在Web请求级别和调用级别确认和授权.在Spring Framewo ...