Codeforces Round #298 (Div. 2) B. Covered Path
题目大意:
一辆车,每秒内的速度恒定...第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的更多相关文章
- 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 ...
- 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 ...
- CodeForces Round #298 Div.2
A. Exam 果然,并没有3分钟秒掉水题的能力,=_=|| n <= 4的时候特判.n >= 5的时候将奇数和偶数分开输出即可保证相邻的两数不处在相邻的位置. #include < ...
- 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 ...
- 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 ...
- Codeforces Round #298 (Div. 2) D. Handshakes 构造
D. Handshakes Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem ...
- 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 ...
- 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 ...
- Codeforces Round #298 (Div. 2)--D. Handshakes
#include <stdio.h> #include <algorithm> #include <set> using namespace std; #defin ...
随机推荐
- HDU 3074 Multiply game(线段树)
单点更新,更新时先除去 原来的数,因为有去摸,可以用乘上逆元代替. //================================================================ ...
- 一模 (5) day1
第一题: 题目大意:求出1-10^n 这些数中,包含数字3的有多少个. n<=1000: 解题过程: 1.这题一看就是高精度+递推..如果n=1000,那么假设个位是3,其他999位任意..那么 ...
- 数列F[19] + F[13]的值
已知数列如下:F[1]=1, F[2]=1, F[3]=5,......,F[n] =F[n-1] + 2*F[n-2],求F[19] + F[13]? #include <stdio.h> ...
- [开发笔记]-flowplayer视频播放插件
最近项目中需要添加播放视频的功能,视频文件是flv格式的.在网上找了一些jQuery视频播放插件,还是觉得“flowplayer”要好一些.特将使用方法记录一下. flowplayer也有html5版 ...
- C++-继承名称的掩盖
/////////////////////////////////////////////////////////////////////////////// // // FileName : eff ...
- POJ 2480 求每一个数对于n的最大公约数的和
这里是枚举每一个最大公约数p,那么最后求的是f(n) = sigma(p*phi(n/p)) phi()为欧拉函数 这里可以试着算一下,然后会发现这个是积性函数的 那么只要考虑每一类质数分开算, ...
- obj.offsetHeight与obj.style.height区别
我们都知道obj.offsetHeight与obj.style.height都可以获取obj的高度,但是在js使用中,我们通常会使用前者来获取高度,这是为什么,二者有什么样的区别呢. 1.obj.of ...
- wince6.0 开机启动定制的程序
1.prject.bib MediaApp.exe $(_FLATRELEASEDIR)\MediaApp.exe NK H MediaApp.lnk $(_FLATRELEASEDIR)\Media ...
- [安卓]softap
http://www.cnblogs.com/javawebsoa/archive/2013/05/29/3106758.html
- <二叉树的基本操作(有层次遍历)>
#include<stdio.h> #include<stdlib.h> #include<string.h> #define num 100 #define OK ...