CodeForces 534B Covered Path (水题)
2016-08-02 09:18
253 查看
题意:给定两个速度,一个一初速度,一个末速度,然后给定 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; }
相关文章推荐
- zabbix 日志
- Android实现IOS相机滑动控件
- Servlet学习教程(一)----什么是Servlet以及Servlet容器
- phash安装
- python学习——编写Model
- c++回调函数
- 前端面试的坑(三)
- 解读jQuery筛选器children()
- 关于block使用的5点注意事项
- HashSet与HashMap的区别
- 浅谈Cookie的生命周期问题
- 生成树算法的网桥协议STP(Spanning Tree Protocol)
- TCP协议如何来保证传输的可靠性和数据的顺序性
- Scala开发入门教程
- Netfilter的使用和实现
- jQuery实现的兼容性浮动层示例
- HDU 3801 Query on a tree(树链剖分离线处理)
- ArcGIS Engine开发之旅02--ArcGIS Engine中的类库
- [用户管理]——用户与组管理的文件、命令
- 标准I/O和管道