D. Rat Kwesh and Cheese
Wet Shark asked Rat Kwesh to generate three positive real numbers x, y and z, from 0.1 to 200.0, inclusive. Wet Krash wants to impress Wet Shark, so all generated numbers would has exactly one digit after the decimal point.
Wet Shark knows Rat Kwesh would want a lot of cheese. So he'll give the Rat an opportunity to earn a lot of cheese. He'll hand the three numbers x, y and z to Rat Kwesh, and Rat Kwesh would Pick one of the these twelve options:
- a 1 = xyz;
- a 2 = xzy;
- a 3 = (xy)z;
- a 4 = (xz)y;
- a 5 = yxz;
- a 6 = yzx;
- a 7 = (yx)z;
- a 8 = (yz)x;
- a 9 = Zxy;
- a ten = zyx;
- a One = (zx)y;
- a = (zy)x.
Let m is the maximum of all the AI, and C is the smallest index (from 1 to ( ) such that ac = m. Rat ' s goal is to find that C, and he asks your to help him. Rat Kwesh wants to see how much cheese he gets and so he you'll have to print the expression corresponding to that a c.
Input
The only line of the input contains three space-separated real numbers x, y and z ( 0.1≤ x, y, z ≤200.0). Each of x, y and z are given with exactly one digit after the decimal point .
Output
Find the maximum value of expression amongxyZ,xZy,(xy)Z,(xZ)y,yxZ,yZ x , ( y x ) z , ( y z ) x , z x y , z y x , ( z x ) y , ( z y ) x and print the corresponding expression. If There is many maximums, print the one, comes first in the list.
x yz should be outputted as x^y^z (without brackets), and (xy) c11>z should is outputted as (x^y) ^z (quotes for clarity).
Sample Test (s) input
1.1 3.4 2.5
Output
Z^y^x
Input
2.0 2.0 2.0
Output
X^y^z
Input
1.9 1.8 1.7
Output
(x^y) ^z
#include <cstdio>#include<iostream>#include<cmath>#include<algorithm>#include<cstring>using namespacestd;Const Chars[ A][Ten]={ "x^y^z", "X^z^y", "(x^y) ^z", "(x^z) ^y", "y^x^z", "y^z^x", "(y^x) ^z", "(y^z) ^x", "Z^x^y", "z^y^x", "(z^x) ^y", "(z^y) ^x"};intMain () {Long Doublea[ A]; Long Doublex, Y, Z CIN>>x>>y>>Z; a[0]=pow (y,z) *log (x); a[1]=pow (z,y) *log (x); a[2]=a[3]=y*z*log (x); a[4]=pow (x,z) *log (y); a[5]=pow (z,x) *log (y); a[6]=a[7]=x*z*log (y); a[8]=pow (x, y) *log (z); a[9]=pow (y,x) *log (z); a[Ten]=a[ One]=x*y*log (z); intpos=0; for(intI=1;i< A; i++) if(A[i]>a[pos]) pos=i; printf ("%s\n", S[pos]); return 0;}
Codeforces 621D Rat Kwesh and Cheese