CF987B High School: Become Human 数学
Posted zxyqzy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF987B High School: Become Human 数学相关的知识,希望对你有一定的参考价值。
题意翻译
题目大意
输入一个 xxx ,一个 yyy ,求是 xyx^yxy 大还是 yxy^xyx 大。 (1≤x,y≤109)(1≤x,y≤10^9)(1≤x,y≤109)
输入输出格式
输入格式
一行,两个整数 x,yx,yx,y 。
输出格式
若 xyx^yxy > yxy^xyx ,输出">",若 xyx^yxy < yxy^xyx ,输出"<",想等则输出"="。
感谢@二元长天笑 提供的翻译
题目描述
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 xy x^y xy with yx y^x yx . 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 xy x^y xy with yx y^x yx for Vasya, maybe then other androids will respect him.
输入输出格式
输入格式:On the only line of input there are two integers x x x and y y y ( 1≤x,y≤109 1 le x, y le 10^{9} 1≤x,y≤109 ).
输出格式:If xy<yx x^y < y^x xy<yx , then print ‘<‘ (without quotes). If xy>yx x^y > y^x xy>yx , then print ‘>‘ (without quotes). If xy=yx x^y = y^x xy=yx , then print ‘=‘ (without quotes).
输入输出样例
说明
In the first example 58=5?5?5?5?5?5?5?5=390625 5^8 = 5 cdot 5 cdot 5 cdot 5 cdot 5 cdot 5 cdot 5 cdot 5 = 390625 58=5?5?5?5?5?5?5?5=390625 , and 85=8?8?8?8?8=32768 8^5 = 8 cdot 8 cdot 8 cdot 8 cdot 8 = 32768 85=8?8?8?8?8=32768 . So you should print ‘>‘.
In the second example 103=1000<310=59049 10^3 = 1000 < 3^{10} = 59049 103=1000<310=59049 .
In the third example 66=46656=66 6^6 = 46656 = 6^6 66=46656=66 .
注意用 long double;
#include<iostream> #include<cstdio> #include<algorithm> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #include<vector> #include<queue> #include<bitset> #include<ctime> #include<deque> #include<stack> #include<functional> #include<sstream> //#include<cctype> //#pragma GCC optimize(2) using namespace std; #define maxn 900005 #define inf 0x7fffffff //#define INF 1e18 #define rdint(x) scanf("%d",&x) #define rdllt(x) scanf("%lld",&x) #define rdult(x) scanf("%lu",&x) #define rdlf(x) scanf("%lf",&x) #define rdstr(x) scanf("%s",x) typedef long long ll; typedef unsigned long long ull; typedef unsigned int U; #define ms(x) memset((x),0,sizeof(x)) const long long int mod = 1e9 + 7; #define Mod 1000000000 #define sq(x) (x)*(x) #define eps 1e-4 typedef pair<int, int> pii; #define pi acos(-1.0) //const int N = 1005; #define REP(i,n) for(int i=0;i<(n);i++) typedef pair<int, int> pii; inline ll rd() { ll x = 0; char c = getchar(); bool f = false; while (!isdigit(c)) { if (c == ‘-‘) f = true; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return f ? -x : x; } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); } int sqr(int x) { return x * x; } /*ll ans; ll exgcd(ll a, ll b, ll &x, ll &y) { if (!b) { x = 1; y = 0; return a; } ans = exgcd(b, a%b, x, y); ll t = x; x = y; y = t - a / b * y; return ans; } */ int x, y; long double ans1, ans2; int main() { //ios::sync_with_stdio(0); cin >> x >> y; ans1 = (long double)y*log(x)*1.0; ans2 = (long double)x*log(y)*1.0; if (ans1 > ans2)cout << ">" << endl; else if (ans2 > ans1)cout << "<" << endl; else if (fabs(ans1 - ans2) <= eps)cout << "=" << endl; return 0; }
以上是关于CF987B High School: Become Human 数学的主要内容,如果未能解决你的问题,请参考以下文章
题目:B. High School: Become Human
High School: Become Human(数学思维)