http://codeforces.com/contest/1011/problem/C 题目

这是一道大水题!

仅以此题解作为我这个蒟蒻掉分的见证

 #include<iostream>
#include<cstdio>
#include <cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
#define mem(a,x) memset(a,x,sizeof(a))
#define se second
#define fi first
const int INF= 0x3f3f3f3f;
const int N=1e7+; int n,m,a[],b[]; bool check(double x)
{
double sum=m+x; if(sum>m)
sum-= sum/a[]; //从地球起飞
else return ;
for(int i=;i<=n;i++) //for循环里面都是在除地球外 各个星球上的降落起飞
{
if(sum>m)
sum-=sum/a[i];
else return ;
if(sum>m)
sum-=sum/b[i];
else return ;
}
if(sum>m)
sum-=sum/b[]; //最后降落地球
else return ; if(sum>=m) return ; //燃料 = sum-m 如果燃料>=0 表示可以
else return ;
} int main()
{
cin>>n>>m;
for(int i=;i<=n;i++) scanf("%d",&a[i]);
for(int i=;i<=n;i++) scanf("%d",&b[i]); double l=,r=1e9+10,mid,ans=-; //r不能正好 1e9,不然有个mid=1e9的点过不去
int flag=;
while(r-l>=1e-) //1e-7会超时,而且题目也要求了1e-6就够了
{
mid=(l+r)/2.0;
if(check(mid))
{
ans=mid;
r=mid;
flag=;
}
else l=mid;
}
if(!flag)cout<<-;
else printf("%.10f",ans);
}

Codeforces Round #499(Div2) C. Fly (二分精度)的更多相关文章

  1. CodeForces Round #499 Div2

    A: Stages 题意: 给你n个字符, 现在需要从中选取m个字符,每个字符的花费为在字母表的第几位,并且如果选了某个字符, 那么下一个选择的字符必须要在字母表的2位之后, 假如选了e 那么 不能选 ...

  2. Codeforces Round #499 (Div. 1)

    Codeforces Round #499 (Div. 1) https://codeforces.com/contest/1010 为啥我\(\rm Div.1\)能\(A4\)题还是\(\rm s ...

  3. Codeforces Round #499 (Div. 2)

    Codeforces Round #499 (Div. 2) https://codeforces.com/contest/1011 A #include <bits/stdc++.h> ...

  4. Codeforces Round #499 (Div. 1)部分题解(B,C,D)

    Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...

  5. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  6. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  7. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  8. Codeforces Round #499 (Div. 1) F. Tree

    Codeforces Round #499 (Div. 1) F. Tree 题目链接 \(\rm CodeForces\):https://codeforces.com/contest/1010/p ...

  9. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  10. 7-27 Codeforces Round #499 (Div. 2)

    C. Fly 链接:http://codeforces.com/group/1EzrFFyOc0/contest/1011/problem/C 题型:binary search .math. 题意:总 ...

随机推荐

  1. Linux下,postgreSQL的查看与重启

    查看命令:ps aux | grep postgresnetstat -npl | grep postgres 方法1: #su - postgres $pg_ctl restart 方法2: #su ...

  2. docker 在 centos7.* 上的部署及问题解决

    最近尝试搭建docker 环境,其实个人是比较喜欢“菜鸟学习系列”的知识的,怎奈它的讲解是以Ubuntu为主的,最后找到一个搭建学习系列,感觉写的很好,主要是页面风格清晰明了,遂决定按照此教程学习搭建 ...

  3. linux 使用jar 打包成war

    把当前目录下的所有文件打包成game.war jar -cvfM0 game.war ./ -c   创建war包 -v   显示过程信息 -f     -M -0   这个是阿拉伯数字,只打包不压缩 ...

  4. GridView取不到值的问题总结

    在ASP.NET开发过程中,使用GridView进行数据表现的时候遇到过两次取不到值的问题.分别是初学的时候与 用了一年多以后.出现的问题并不是身边么高深的技术,但是可能会经常遇到,所以这里我做一下总 ...

  5. Python 常用包收集

    转自:http://www.cnblogs.com/Logic0/archive/2010/09/03/1850382.html 常用的自带类库 常用的外部类库       Tkinter———— P ...

  6. Zero-shot Learning / One-shot Learning / Few-shot Learning

    Zero-shot Learning / One-shot Learning / Few-shot Learning Learning类型:Zero-shot Learning.One-shot Le ...

  7. 《Mysql - 在Mysql服务出现瓶颈时,有哪些“饮鸩止渴”提高性能的方法?》

    一:情景 - 业务高峰期,生产环境的 MySQL 压力太大,没法正常响应,需要短期内.临时性地提升一些性能. - 在业务高发时候,Mysql 服务压力过大,导致业务受损, 用户的开发负责人说,不管你用 ...

  8. ubuntu下安装amqp扩展

    目录 环境 下载扩展: 安装amqp: 验证 环境 系统 ubuntu 16.04 php 7.1 下载扩展: sudo apt-get -y install gcc make autoconf li ...

  9. Struts笔记3

    struts标签 form表单标签 Action:请求地址.直接写动作名称,不用写contextPath <s:form action="/user/register.action&q ...

  10. CSS中的position和float

    对基础知识再度做个巩固和梳理. 一.position定位 (一):position的属性 1.absolute:生成绝对定位的元素,相对于最近一级定位不是static的父元素来进行定位: 2.rela ...