题意:给定两个速度,一个一初速度,一个末速度,然后给定 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. 13.Object-C--浅谈Foundation框架常用的结构体

    ------- android培训.iOS培训.期待与您交流! ---------- 昨天学习了Foundation框架中常用的结构体,下面我简单的总结一下,如果错误麻烦请留言指正,谢谢! Found ...

  2. BZOJ 1452 Count

    长知识啦..二维BIT. #include<iostream> #include<cstdio> #include<cstring> #include<alg ...

  3. QCon 2015 阅读笔记 - 移动开发最佳实践

    所有ppt下载地址:http://pan.baidu.com/s/1mg9o4TM 下面是移动开发实践部分的阅读笔记. 移动开发网络性能优化实践 - 陈浩然 (携程) 携程是非常标准的移动App架构, ...

  4. php flock注意事项

    对于实际的运用,必须将其添加到所有使用的文件脚本中 但注意:其函数无法再NFS或其他网络文件系统中使用也无法在多线程服务器API中使用.

  5. IOS设计模式之三(适配器模式,观察者模式)

    本文原文请见:http://www.raywenderlich.com/46988/ios-design-patterns. 由 @krq_tiger(http://weibo.com/xmuzyq) ...

  6. 用Python抓网页的注意事项

    用Python编一个抓网页的程序是非常快的,下面就是一个例子: import urllib2 html = urllib2.urlopen('http://blog.raphaelzhang.com' ...

  7. centos下安装xfce+vnc

    首先安装桌面环境,我选择的是xfce,轻量级桌面,小巧实用不占太多内存,(占用内存方面,xfce少于kde,kde少于gnome). 安装xfce桌面一开始我以为第三方的软件源如rpmforge等应该 ...

  8. nodejs的调试(node-inspector)

    我们在接触客户端javascript的时候,调试利器就是firebug ,也是当年为何喜欢用上firefox 浏览器的主要动力,当然,后来 chrome 插件里也出现了firebug的身影..... ...

  9. Android布局文件夹引起的问题

    Android 运行到setContentView(R.layout.splash); 总是出现如下的错误: java.lang.RuntimeException: Unable to start a ...

  10. MySQL · 性能优化· InnoDB buffer pool flush策略漫谈

    MySQL · 性能优化· InnoDB buffer pool flush策略漫谈 背景 我们知道InnoDB使用buffer pool来缓存从磁盘读取到内存的数据页.buffer pool通常由数 ...