您的位置:首页 > 其它

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: