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).
輸入輸出樣例
輸入樣例#1: 復制5 8輸出樣例#1: 復制
>輸入樣例#2: 復制
10 3輸出樣例#2: 復制
<輸入樣例#3: 復制
6 6輸出樣例#3: 復制
=
說明
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 數學