HDU 2268 How To Use The Car (数学题)

题目

//做起来很艰辛,总结起来很简单。。。

//注意步行速度可能比车的速度快。。。。

//推公式要仔细,,,,

//一道对我来说很搞脑子的数学题,,,,,
//车先送第一个人上路,第二个人步行;中途第一个人下车步行,车回去接第二个人直接到终点
//L:第一个人步行的路程;
//T:总时间
//(c-L)*a/b+L+((L/a-L/b)/2)*(a+b)=c   -->>  L=2*a*c/(3*a+b)
//T=(c-L)/b+L/a

//坑啊,要比较车速快还是步行快!!!!采取不同方案。。。。。

//中途推出来了(案例顺利通过),交上去却wa,还以为精度问题或是超出了int,改了半天才发现推错了,,笨死拉,,,
//tmd,推数学公式真要仔细啊,一不小心就会出错。。。

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    double time,a,b,c;
    while(scanf("%lf%lf%lf",&a,&b,&c)!=EOF)
    {
        if(a>=b)time=c*1.0/a;
        else {
            double L=2*a*c/(3*a+b);
            time=(c-L)/b+L/a;
        }
        printf("%.3lf\n",time);
    }
    return 0;
}

时间: 2024-12-25 16:21:35

HDU 2268 How To Use The Car (数学题)的相关文章

hdu 4974 A simple water problem(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4974 Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or

HDU 3105 Fred&#39;s Lotto Tickets(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3105 Problem Description Fred likes to play the lotto. Whenever he does, he buys lots of tickets. Each ticket has 6 unique numbers in the range from 1 to 49, inclusive. Fred likes to ``Cover all his base

hdu 1165 Eddy&amp;#39;s research II(数学题,递推)

// Eddy 继续 Problem Description As is known, Ackermann function plays an important role in the sphere of theoretical computer science. However, in the other hand, the dramatic fast increasing pace of the function caused the value of Ackermann function

HDU 1785 You Are All Excellent(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1785 Problem Description 本次集训队共有30多人参加,毫无疑问,你们都是很优秀的,但是由于参赛名额有限,只能选拔部分队员参加省赛.从学校的角度,总是希望选拔出最优秀的18人组成6支队伍来代表学校.但是,大家也知道,要想做到完全客观,是一件很难的事情.因为选拔的标准本身就很难统一. 为了解决这个难题,我现在把问题作了简化,现在假设每个队员都是二维平面中的一个点,用(xi,yi)坐标

HDU 1326 Box of Bricks(简单数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1326 Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. ``Look, I've built a wall!'', he tells his older siste

HDU - 2058 The sum problem(简单数学题)

题意:求出所有的情况,等差上去可以达到m值. 原来想着暴力搜索,但是题中的数据太大,所以时间超限. 百度了一下,发现可以套公式. 等差求和公式: Sn=(a1+aN)*n/2     =(a1+a1+d(n-1))*n/2     =a1*n+d(n-1)*n/2; 因为此处公差d=1,所以Sn=a1*n+(n-1)*n/2,当从第一项开始算起时(因本题首项为1,即a1=1时),Sn=M时的项的个数n最多; a1=1,现在又可化简为Sn=n+(n-1)*n/2=(n+1)n/2; 由题意得M=S

hdu 2076 夹角有多大(题目已修改,注意读题)

http://acm.hdu.edu.cn/showproblem.php?pid=2076 数学题...公式推出来就可以AC了. 思路:分别求出时针和分针与12点的位置的夹角大小,输出夹角的差值,注意取小于180度的角. 代码如下: #include<stdio.h> int main() { int t; double h,m,s,angle1,angle2,angle; while(scanf("%d",&t)!=EOF) { while(t--) { sca

hdu 4956 Poor Hanamichi BestCoder Round #5(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956 Poor Hanamichi Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7    Accepted Submission(s): 4 Problem Description Hanamichi is taking part in

hdu 1012:u Calculate e(数学题,水题)

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28686    Accepted Submission(s): 12762 Problem Description A simple mathematical formula for e iswhere n is allowed to go to infinit