2019湖南多校第5场网络同步赛A

Description

Anna loves her cell phone and becomes very sad when its battery level drops to 0 percent.

In normal mode, Anna's phone battery drains at a constant speed. When the battery level reaches 20 percent, the phone automatically switches to eco mode. In eco mode, the battery drains two times slower than in normal mode.

Alex has invited Anna for a date. Anna needs t minutes to get from her home to the meeting place. When Anna leaves home, her phone's battery level is 100 percent. At the moment she reaches the meeting place, the battery level will be p percent.

Alex wonders for how long Anna will be in a good mood after they meet. Help him solve this problem!

Input

The only line of the input contains two integers t and p --- time Anna needs to get from her home to the meeting place, in minutes, and the battery level of her phone at the moment of meeting, in percent (1 ≤ t ≤ 360; 1 ≤ p ≤ 99).

Output

Output a single real number --- time since the moment of meeting before Anna's phone runs out of battery, in minutes.

Your answer will be considered correct if its absolute or relative error doesn't exceed 10−4.

Sample Input

30 70

Sample Output

90.0 

Hint

In the first test case, the battery drains at a rate of one percent per minute. In 50 minutes after the meeting, the battery level will reach 20 percent and the phone will switch to eco mode. 40 minutes later the phone will run out of battery.

这题实际要保存5位小数。。。样例居然误导我。。。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    double t,p;
    while(scanf("%lf %lf",&t,&p)!=EOF)
    {
        double x;
        if(p>=20.0)
        {
            x=(100.0-p)/t;
            printf("%.5f\n",(p-20.0)/x+40.0/x);
        }
        else
        {
            x=(120-2*p)/t;
            printf("%.5f\n",2*p/x);
        }
    }

    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值