题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离。

析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推。

代码如下:

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int maxn = 1e5 + 5;
const int INF = 0x3f3f3f3f;
vector<int> ans;
int a[1005]; int main(){
int d, v1, v2, t;
scanf("%d %d %d %d", &v1, &v2, &t, &d);
int ans = 0;
for(int i = 0; i < t; ++i)
a[i] = i * d + v2;
for(int i = 0; i < t; ++i){
if(v1 + d * i > a[t-1-i]){
ans += a[t-1-i]; }
else {
ans += v1 + d * i;
}
}
cout << ans << endl;
return 0;
}

CodeForces 534B Covered Path (水题)的更多相关文章

  1. Codeforces 534B - Covered Path

    534B - Covered Path 思路:贪心,每一秒取尽可能大并且可以达到的速度. 画张图吧,不解释了: 代码: #include<bits/stdc++.h> using name ...

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

  3. Codeforces Gym 100531G Grave 水题

    Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...

  4. codeforces 706A A. Beru-taxi(水题)

    题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...

  5. codeforces 569B B. Inventory(水题)

    题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  6. Codeforces 489A SwapSort (水题)

    A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  7. codeforces 688A A. Opponents(水题)

    题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  8. Codeforces Gym 100286I iSharp 水题

    Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  9. CodeForces 705A(训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...

随机推荐

  1. Asp.Net验证码2

    using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System. ...

  2. Android init.rc文件格式解析

    /***************************************************************************** * Android init.rc文件格式 ...

  3. Using newInstance() to Instantiate a Fragment(转)

    I recently came across an interesting question on StackOverflow regarding Fragment instantiation: Wh ...

  4. 09day1

    词编码 模拟 [问题描述] 一个发送机可以通过一条隧道发送一些以二进制代码组成的单词.在其尽头的接受机可以使用特殊技术恢复到最初的单词.每个单词最初都由0和1组成.所有的单词最初长度都为n(4< ...

  5. JVM内存结构——运行时数据区

    在Java虚拟机规范中将Java运行时数据划分为6种,分别为: PC寄存器(程序计数器) Java栈 堆 方法区 运行时常量池 本地方法栈 一.PC寄存器(程序计数器) PC寄存器(Program C ...

  6. smtp邮件营销吧

    SPF 设置说明: 首先你必须有自己的域名.没有的话是不可能设置 SPF 的. SPF 是域名的一条 TXT 记录. 如果你的邮箱服务器是企业邮箱服务商的,可以在自己的 SPF 中直接包含服务商 SP ...

  7. selenium + python 多浏览器测试

    selenium + python 多浏览器测试 支持库包 在学习 Python + Selenium 正篇之前,先来看下对多浏览器模拟的支持.目前selenium包中已包含webdriver,hel ...

  8. Linux系统上安装Python

    1.下载Python安装包,官网下:http://www.python.org/getit/ http://jingyan.baidu.com/article/eae07827f7f2d01fec54 ...

  9. 【c++】输出 0000,0001,0002,0003,0004...这样的字符串

    #include <iostream> #include <iomanip> ; ){ stringstream buf; buf <<setfill()<& ...

  10. c++ 小知识总结 .xml

    pre{ line-height:1; color:#800080; background-color:#d2c39b; font-size:16px;}.sysFunc{color:#627cf6; ...