• Codeforces Round #485 (Div. 2) B. High School: Become Human


    Codeforces Round #485 (Div. 2) B. High School: Become Human

    题目连接:

    http://codeforces.com/contest/987/problem/B

    Description

    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 $x^y$ with $y^x$. 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 $x^y$ with $y^x$ for Vasya, maybe then other androids will respect him.

    Sample Input

    5 8
    

    Sample Output

    >
    

    题意

    比较 (x^y)(y^x) 的大小

    Comparing the size of (x^y) and (y^x) .

    题解:

    如果有 (a=b),则有(log(a)=log(b)),利用log的运算,将乘法变成加法。

    if we have (a=b),we will get (log(a)=log(b)).Changing the calculating method.

    代码

    #include <bits/stdc++.h>
    
    using namespace std;
    
    using ll = long long;
    ll q,w;
    
    
    int main() {
        cin>>q>>w;
        if (log10(q)*w-log10(w)*q>1e-8)
            return 0*puts(">");
        else if (-log10(q)*w+log10(w)*q>1e-8)
            return 0*puts("<");
        else return 0*puts("=");
    }
    
    
  • 相关阅读:
    opencv3.2.0形态学滤波之腐蚀
    Ubuntu下卸载QT5.7.1再重装
    opencv3.2.0形态学滤波之膨胀
    Direct3D中的绘制
    绘制流水线
    初始化Direct3D
    VS2012添加对DirectX SDK中需要文件的引用
    ASCII,Unicode 和通用方式
    对话框访问的7种方式【孙鑫老师教程】
    函数指针
  • 原文地址:https://www.cnblogs.com/EDGsheryl/p/9156782.html
Copyright © 2020-2023  润新知