Codeforces Round #298 (Div. 2) B. Covered Path
题目大意:
一辆车,每秒内的速度恒定...第I秒到第I+1秒的速度变化不超过D。初始速度为V1,末速度为V2,经过时间t,问最远能走多远。
分析
开始的时候想麻烦了。讨论了各种情况。后来发现每个时刻的最大值都满足一定的约束关系。设此时为时刻i,上一次的速度为p,那么本次的速度应为max(p+d,v2+(t-i)*d),因为要保证最终一定能够返回到v2。这样以来便可以得到每个时刻的最大值,然后累加求和即可。
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int v1,v2,t,d;
int a[];
while(scanf("%d %d",&v1,&v2)!=EOF)
{
scanf("%d %d",&t,&d);
a[]=v1;
int k=,tem=v1;
for(int i=;i<=t;i++)
{
tem=min(tem+d,v2+(t-i)*d);
a[++k]=tem;
}
int sum=;
for(int i=;i<=k;i++)
sum+=a[i];
printf("%d\n",sum);
}
return ;
}
Codeforces Round #298 (Div. 2) B. Covered Path的更多相关文章
- Codeforces Round #298 (Div. 2) B. Covered Path 物理题/暴力枚举
B. Covered Path Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/probl ...
- Codeforces Round #298 (Div. 2) A、B、C题
题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...
- CodeForces Round #298 Div.2
A. Exam 果然,并没有3分钟秒掉水题的能力,=_=|| n <= 4的时候特判.n >= 5的时候将奇数和偶数分开输出即可保证相邻的两数不处在相邻的位置. #include < ...
- Codeforces Round #298 (Div. 2)A B C D
A. Exam time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
- Codeforces Round #298 (Div. 2) E. Berland Local Positioning System 构造
E. Berland Local Positioning System Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.c ...
- Codeforces Round #298 (Div. 2) D. Handshakes 构造
D. Handshakes Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem ...
- Codeforces Round #298 (Div. 2) C. Polycarpus' Dice 数学
C. Polycarpus' Dice Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/p ...
- Codeforces Round #298 (Div. 2) A. Exam 构造
A. Exam Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem/A Des ...
- Codeforces Round #298 (Div. 2)--D. Handshakes
#include <stdio.h> #include <algorithm> #include <set> using namespace std; #defin ...
随机推荐
- js获取浏览器的版本代码
<script>function GetXmlHttpObject(){var xmlHttp=null;var httptype='';try { // Firefox, Opera 8 ...
- js打印对象(object)
function printObject(obj){//obj = {"cid":"C0","ctext":"区县"}; ...
- c实现的iOS http下载类。支持自己设定http 头(比如cookie等)
也许有人要问为什么要自己用c写? 原因是: 1 我是菜鸟 2 我最最初选择了AsyncSocket,弄了很久,基本上稳定了,但有时候出现了数据不完整,但我又没办法在这个时候识别到并重试:所以不完美,最 ...
- C# DES加密
需要引用名称空间 using System; using System.Text; using System.Security.Cryptography; using System.IO; 具体代码: ...
- ASP.NET MVC过滤器(一)
MVC过滤器是加在 Controller 或 Action 上的一种 Attribute,通过过滤器,MVC 网站在处理用户请求时,可以处理一些附加的操作,如:用户权限验证.系统日志.异常处理.缓存等 ...
- dedecms二级菜单实现
修改channelartlist.lib.php if($typeid==0 || $typeid=='top') { $tpsql = " reid=0 AND ispart<> ...
- GET /hello/fred/0926xxx572
GET /hello/fred/0926xxx572 app.get('/hello/:name/:tel', function(req, res) { console.log(req.params. ...
- angular-xeditable
http://vitalets.github.io/angular-xeditable/#text-simple ng-repeat="user in users" e-rows= ...
- python下的复杂网络编程包networkx的安装及使用
由于py3.x与工具包的兼容问题,这里采用py2.7 1.python下的复杂网络编程包networkx的使用: http://blog.sina.com.cn/s/blog_720448d30101 ...
- Problem C HDU 5224
Description There is a piece of paper in front of Tom, its length and width are integer. Tom knows t ...