Sheryl's ACM

一条默默划水的咸鱼

导航

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("=");
}

posted on 2018-06-08 17:28  EDGsheryl  阅读(242)  评论(0编辑  收藏  举报