zoukankan      html  css  js  c++  java
  • 牛客小白月赛6 B 范围 数学

    链接:https://www.nowcoder.com/acm/contest/135/B
    来源:牛客网

    题目描述

    已知均为实数,且满足:

    给定A,B,求x的取值范围

    由于Apojacsleam的计算几何往往被精度卡飞,所以他痛恨精度错误,于是给定的A,B都是正整数
    请注意:题目中给的指的是仅为某些可以取任何值的变量名,与x没有任何关系

    输入描述:

    输入数据共一行,两个正整数A,B,意义如“题目描述”。

    输出描述:

    输出一行描述答案:

    若有解,输出多个实数(至少两个),从小到大输出,保留两位小数,表示X的取值范围的端点,无解输出”No Answer.”(不含引号)

    注:如果端点有两个,以下四种情况的答案都是L,R:
    请注意,如果L=R,则需要输出两次
    示例1

    输入

    复制
    3 5

    输出

    复制
    1.00 2.00

    说明

     
    分析:
     

                           

    附带柯西不等式:

                                        

    参考博客:https://blog.csdn.net/haut_ykc/article/details/81366113

    AC代码:

    #include <map>
    #include <set>
    #include <stack>
    #include <cmath>
    #include <queue>
    #include <cstdio>
    #include <vector>
    #include <string>
    #include <bitset>
    #include <cstring>
    #include <iomanip>
    #include <iostream>
    #include <algorithm>
    #define ls (r<<1)
    #define rs (r<<1|1)
    #define debug(a) cout << #a << " " << a << endl
    using namespace std;
    typedef long long ll;
    const ll maxn = 1e6+10;
    const double eps = 1e-8;
    const ll mod = 1e9 + 7;
    const int inf = 0x3f3f3f3f;
    const double pi = acos(-1.0);
    int main() {
        ios::sync_with_stdio(0);
        double a, b;
        cin >> a >> b;
        double t = sqrt(2.0*b-a*a);
        printf("%.2lf %.2lf
    ",a/2-t/2,a/2+t/2);
        return 0;
    }
    

      

    彼时当年少,莫负好时光。
  • 相关阅读:
    【WCF--初入江湖】04 WCF通信模式
    【WCF--初入江湖】03 配置服务
    c++输出左右对齐设置
    setw()函数
    clion更改大括号的位置
    emacs org-mode 中文手册精简版(纯小白)
    c++ string 类型 大小写转换 
    C++中string类型的find 函数
    string类型 C++
    统计单词数---单词与空格
  • 原文地址:https://www.cnblogs.com/l609929321/p/9529799.html
Copyright © 2011-2022 走看看