zoukankan      html  css  js  c++  java
  • B. High School: Become Human

    B. High School: Become Human
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Year 2118. Androids are in mass production for decades now, and they do all the work for humans. But androids have to go to school to be able to solve creative tasks. Just like humans before.

    It turns out that high school struggles are not gone. If someone is not like others, he is bullied. Vasya-8800 is an economy-class android which is produced by a little-known company. His design is not perfect, his characteristics also could be better. So he is bullied by other androids.

    One of the popular pranks on Vasya is to force him to compare xyxy with yxyx. Other androids can do it in milliseconds while Vasya's memory is too small to store such big numbers.

    Please help Vasya! Write a fast program to compare xyxy with yxyx for Vasya, maybe then other androids will respect him.

    Input

    On the only line of input there are two integers xx and yy (1x,y1091≤x,y≤109).

    Output

    If xy<yxxy<yx, then print '<' (without quotes). If xy>yxxy>yx, then print '>' (without quotes). If xy=yxxy=yx, then print '=' (without quotes).

    Examples
    input
    Copy
    5 8
    
    output
    Copy
    >
    
    input
    Copy
    10 3
    
    output
    Copy
    <
    
    input
    Copy
    6 6
    
    output
    Copy
    =
    
    Note

    In the first example 58=55555555=39062558=5⋅5⋅5⋅5⋅5⋅5⋅5⋅5=390625, and 85=88888=3276885=8⋅8⋅8⋅8⋅8=32768. So you should print '>'.

    In the second example 103=1000<310=59049103=1000<310=59049.

    In the third example 66=46656=6666=46656=66.

    思路:

    x^y  与 y^x 比较大小,由数据范围肯定不能乘算,所以可以变换一下   两边取对数  y*log(x) 与 x*log(y)比较  ,取对数结果要取long double 类型 !!!

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main(){
        std::ios::sync_with_stdio(false);
    //    std::cin.tie();
    //    std::cout.tie();
        double a,b;
        cin>>a>>b;
        long double x,y;
        x=b*log(a);
        y=a*log(b);
    //    x=1/a*log(a);   //上下两种都可以
    //    y=1/b*log(b);
        if(x==y) {
            cout<<"="<<endl;
            return 0;
        }
        if(x<y) cout<<"<"<<endl;
        else cout<<">"<<endl;
        return 0;
    }
    



  • 相关阅读:
    Moebius实现Sqlserver集群~介绍篇
    知方可补不足~SQL数据库用户的克隆,SQL集群的用户同步问题
    从零开始学C++之动态创建对象
    [置顶] 某大型银行深化系统技术方案之二十五:性能设计之主要数量指标
    POJ 1300 Door Man
    解决SQL查询总是超时已过期
    hdu 1728 逃离迷宫(BFS)
    Nginx 负载均衡-加权轮询策略剖析
    ios 6 横竖屏转换
    firefox同步数据时无响应问题
  • 原文地址:https://www.cnblogs.com/acerkoo/p/9490329.html
Copyright © 2011-2022 走看看