D. Rat Kwesh and Cheese

题目连接:

http://www.codeforces.com/contest/621/problem/D

Description

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 will have exactly one digit after the decimal point.

Wet Shark knows Rat Kwesh will want a lot of cheese. So he will give the Rat an opportunity to earn a lot of cheese. He will hand the three numbers x, y and z to Rat Kwesh, and Rat Kwesh will pick one of the these twelve options:

a1 = xyz;
a2 = xzy;
a3 = (xy)z;
a4 = (xz)y;
a5 = yxz;
a6 = yzx;
a7 = (yx)z;
a8 = (yz)x;
a9 = zxy;
a10 = zyx;
a11 = (zx)y;
a12 = (zy)x.
Let m be the maximum of all the ai, and c be the smallest index (from 1 to 12) such that ac = m. Rat's goal is to find that c, and he asks you to help him. Rat Kwesh wants to see how much cheese he gets, so he you will have to print the expression corresponding to that ac.

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 is given with exactly one digit after the decimal point.

Output

Find the maximum value of expression among xyz, xzy, (xy)z, (xz)y, yxz, yzx, (yx)z, (yz)x, zxy, zyx, (zx)y, (zy)x and print the corresponding expression. If there are many maximums, print the one that comes first in the list.

xyz should be outputted as x^y^z (without brackets), and (xy)z should be outputted as (x^y)^z (quotes for clarity).

Sample Input

1.1 3.4 2.5

Sample Output

z^y^x

Hint

题意

12个表达式,让你输出最大的表达式

题解:

这个方法是Hezhu的,Orz

太厉害了

我们仔细想一想,次方这个乱七八糟的东西,我们显然可以直接取一个log

但是这个东西还是有200^200,按照题解的方法,你还得取个log,然后再讨论一堆东西

这个太麻烦了

直接上long double就好了,long double 这个东西有自带的powl,logl函数,可以精度更加精确,而且这个玩意儿是存储的科学计数法

总之比较玄学。

最差情况,我想的是,有效数数字就应该只需要16位吧?

代码

#include<bits/stdc++.h>
using namespace std;string s[12]={"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"};
long double d[12];
int main()
{long double x,y,z;cin>>x>>y>>z;d[0]=powl(y,z)*logl(x);d[1]=powl(z,y)*logl(x);d[2]=z*y*logl(x);d[3]=z*y*logl(x);d[4]=powl(x,z)*logl(y);d[5]=powl(z,x)*logl(y);d[6]=z*x*logl(y);d[7]=z*x*logl(y);d[8]=powl(x,y)*logl(z);d[9]=powl(y,x)*logl(z);d[10]=x*y*logl(z);d[11]=x*y*logl(z);long double mx = -1e16;int idx = 0;for(int i=0;i<12;i++)if(mx<d[i])mx=d[i],idx=i;cout<<s[idx]<<endl;
}

Codeforces Round #341 (Div. 2) D. Rat Kwesh and Cheese 数学相关推荐

  1. Codeforces Round #341 (Div. 2)

    在家都变的懒惰了,好久没写题解了,补补CF 模拟 A - Wet Shark and Odd and Even #include <bits/stdc++.h>typedef long l ...

  2. Codeforces Round #304 (Div. 2) D. Soldier and Number Game 数学 质因数个数

    D. Soldier and Number Game Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

  3. Codeforces Round #127 (Div. 1) E. Thoroughly Bureaucratic Organization 二分 数学

    E. Thoroughly Bureaucratic Organization 题目连接: http://www.codeforces.com/contest/201/problem/E Descri ...

  4. Codeforces Round #410 (Div. 2) D. Mike and distribution 思维+数学

    链接: http://codeforces.com/contest/798/problem/D 题意: 给你两个长度为n的数列a和b,让你选n/2+1个下标,使得2*∑ai>suma,2*∑bi ...

  5. codeforces Round #320 (Div. 2) C. A Problem about Polyline(数学) D. Or Game(暴力,数学)

    解题思路:就是求数 n 对应的二进制数中有多少个 1 #include <iostream> #include<cstdio> using namespace std; int ...

  6. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  7. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  8. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

  9. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

最新文章

  1. 推荐几个超NB的技术公号!
  2. [AGC018 B] Sports Festival 解题报告
  3. 中国工业脚轮行业前景展望及营销战略分析报告2021-2027年
  4. CentOS6.7防火墙(Iptables)的开启与关闭
  5. PX4飞控之导航及任务架构
  6. HDU3549(最大流算法的Dinic算法)
  7. 神奇软件:良心浏览器 纯净无捆绑,还有亿点点好用360极速浏览器X
  8. HTML 常用选择框
  9. 网络层 --- 路由器工作原理
  10. windows置顶程序DeskPins的下载、安装和使用
  11. oracle成批事务处理,Oracle EBS OPM 生产批创建事务处理
  12. 松下PLC FP-XHC60T 程序 两个PLC通信控制11个轴 程序稳定已批量生产 注释完整 带威纶通触摸屏程序
  13. python ftp下载文件
  14. Uber 和 Lyft 在德克斯萨大获全胜
  15. Atom 下载、安装
  16. python输出整数部分和小数_Python 正则表达式:只要整数和小数
  17. python分段线性插值_[Python] 分段线性插值
  18. STM32F4时钟触发ADC双通道采样DMA传输进行FFT+测频率+采样频率可变+显示波形(详细解读)...
  19. 什么是@Component,@Component的作用是什么
  20. 【行业解决方案】人脸识别/智能分析视频安防服务平台EasyCVR,构建智慧人社局培训办事机构远程监控系统

热门文章

  1. 第二组视频:MySQL复制
  2. linux+tomcat+oracle_第二步
  3. Iptables防火墙应用
  4. 解析Linux操作系统文件目录
  5. 关于壳的构架的一些感悟
  6. Windows Server 2003 R2 修复Windows Server 2003
  7. 计算机电容的作用,电容和电感的作用
  8. 数据恢复工具PhotoRec
  9. eeglab教程系列(10)-绘制ERP图像
  10. 脑电信号滤波方式汇总