Codeforces 621D Rat Kwesh and Cheese

Source: Internet
Author: User

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:

  1. a 1 = xyz;
  2. a 2 = xzy;
  3. a 3 = (xy)z;
  4. a 4 = (xz)y;
  5. a 5 = yxz;
  6. a 6 = yzx;
  7. a 7 = (yx)z;
  8. a 8 = (yz)x;
  9. a 9 = Zxy;
  10. a ten = zyx;
  11. a One = (zx)y;
  12. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.