题目大意:

一辆车,每秒内的速度恒定...第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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. CodeForces Round #298 Div.2

    A. Exam 果然,并没有3分钟秒掉水题的能力,=_=|| n <= 4的时候特判.n >= 5的时候将奇数和偶数分开输出即可保证相邻的两数不处在相邻的位置. #include < ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #298 (Div. 2) D. Handshakes 构造

    D. Handshakes Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem ...

  7. 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 ...

  8. 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 ...

  9. Codeforces Round #298 (Div. 2)--D. Handshakes

    #include <stdio.h> #include <algorithm> #include <set> using namespace std; #defin ...

随机推荐

  1. Qt 制作安装包

    Qt 制作在线.离线 安装包 见如下文档

  2. JavaOne 2016——观众得以一睹JShell的威力

    导读 在JavaOne 2016的主题演讲中,Java平台组的首席架构师Mark Reinhold指出Java 9并不仅仅是Jigsaw,针对Java 9,一共包含了85个JEP.我在这里会关注一个他 ...

  3. [Js]弹性运动

    描述:像弹簧一样左右弹动,最后缓慢停下来 一.加减速运动 1.加速运动 var iSpeed=0;iSpeed++; 速度越来越快,最后冲出去 2.减速运动 var iSpeed=20;iSpeed- ...

  4. https://docs.mongodb.org/manual/reference/operator/aggregation/unwind/#examples

    https://docs.mongodb.org/manual/reference/operator/aggregation/unwind/#examples http://www.clusterdb ...

  5. CSU 1021 B(Contest #3)

    Description 从m个不同元素中取出n (n ≤ m)个元素的所有组合的个数,叫做从m个不同元素中取出n个元素的组合数.组合数的计算公式如下: C(m, n) = m!/((m - n)!n! ...

  6. MongoDB C#驱动中Query几个方法 (转)

    Query.All("name", "a", "b");//通过多个元素来匹配数组 Query.And(Query.EQ("nam ...

  7. win8系统 host文件无法修改解决之道

    host文件,路径为:C:\windows\system32\drivers\etc\hosts 方法/步骤: 方法1:用notepad++打开host文件,修改和保存 方法2:(1)首先用管理管权限 ...

  8. php中遍历二维数组并以表格的形式输出

    一.索引数组 <?php //使用array()语句结构将联系人列表中所有数据声明为一个二维数组,默认下标是顺序数字索引 $contact1 = array( //定义外层数组 array(1, ...

  9. 《JAVA学习笔记(14-1---14-7)》

    [14-1]面向对象-继承-概述 /* //描述学生 class Student { //属性 String name; int age; //行为 void study() { System.out ...

  10. ZOJ 3747 - Attack on Titans (递推)

    题意:有三个兵种R,G,C,选取N个排成一列,要求G至少有M个连续的,R至多有K个连续的,问有多少种排列方式. 此题与UVa 10328 - Coin Toss非常相似,都是问某个字符连续出现的种数. ...