zoukankan      html  css  js  c++  java
  • 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("=");
    }
    
    
  • 相关阅读:
    .Matrix-第三篇冲刺随笔
    .Matrix-第二篇冲刺随笔
    Alpha冲刺-第九次冲刺笔记
    Alpha冲刺-第八次冲刺笔记
    Alpha冲刺-第七次冲刺笔记
    Alpha冲刺-第六次冲刺笔记
    Alpha冲刺-第五次冲刺笔记
    Alpha冲刺-第四次冲刺笔记
    Alpha冲刺-第三次冲刺笔记
    Alpha冲刺-第二次冲刺笔记
  • 原文地址:https://www.cnblogs.com/EDGsheryl/p/9156782.html
Copyright © 2011-2022 走看看