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 xyz (without brackets), and (xy)z should be outputted as (xy)z (quotes for clarity).

Sample Input

1.1 3.4 2.5

Sample Output

zyx

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 D. Rat Kwesh and Cheese

    嗯本来想着直接算出来不就行了吗 然后我想到了200^200^200....... 好吧其实也不难取两次log就行了 然后我第一次写出来log就写残了........... log里面的拆分要仔细啊.. ...

  2. Codeforces Round #341 (Div. 2)

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

  3. Codeforces Round #341 (Div. 2) ABCDE

    http://www.cnblogs.com/wenruo/p/5176375.html A. Wet Shark and Odd and Even 题意:输入n个数,选择其中任意个数,使和最大且为奇 ...

  4. Codeforces Round #341 (Div. 2) E. Wet Shark and Blocks dp+矩阵加速

    题目链接: http://codeforces.com/problemset/problem/621/E E. Wet Shark and Blocks time limit per test2 se ...

  5. Codeforces Round #341 Div.2 C. Wet Shark and Flowers

    题意: 不概括了..太长了.. 额第一次做这种问题 算是概率dp吗? 保存前缀项中第一个和最后一个的概率 然后每添加新的一项 就解除前缀和第一项和最后一项的关系 并添加新的一项和保存的两项的关系 这里 ...

  6. Codeforces Round #341 Div.2 B. Wet Shark and Bishops

    题意:处在同一对角线上的主教(是这么翻译没错吧= =)会相互攻击 求互相攻击对数 由于有正负对角线 因此用两个数组分别保存每个主教写的 x-y 和 x+y 然后每个数组中扫描重复数字k ans加上kC ...

  7. Codeforces Round #341 Div.2 A. Wet Shark and Odd and Even

    题意是得到最大的偶数和 解决办法很简单 排个序 取和 如果是奇数就减去最小的奇数 #include <cstdio> #include <cmath> #include < ...

  8. Codeforces Round #341 (Div. 2) E - Wet Shark and Blocks

    题目大意:有m (m<=1e9) 个相同的块,每个块里边有n个数,每个数的范围是1-9,从每个块里边取出来一个数组成一个数,让你求组成的方案中 被x取模后,值为k的方案数.(1<=k< ...

  9. Codeforces Round #341 (Div. 2) C. Mike and Chocolate Thieves 二分

    C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

随机推荐

  1. linux pthread【转】

    转自:http://www.cnblogs.com/alanhu/articles/4748943.html Posix线程编程指南(1) 内容:  一. 线程创建  二.线程取消 关于作者  线程创 ...

  2. "Flags mismatch irq" register interrupt handler error

    Question : When you see the log "Flags mismatch irq ............", maybe you use the same ...

  3. gradle问题总结与理解(一篇文章带你理解android studio 与gradle 的关系)

    前言:近日在网上找了个很不错的安卓二维码美化,由于下载的项目经常出问题,且不方便依赖使用,因此我想把它写个demo,并把源码发布到jcenter中,修改还是很顺利的,运行项目到手机也没问题,发布遇到了 ...

  4. 获取file中字段,写入到TXT文件中

    一下代码省略了很多,哈哈哈 a.txt文件 uid,type,pointx,pointy,name1,9,911233763,543857286,区间测速起点3,9,906371086,5453354 ...

  5. 网站服务器压力Web性能测试(1):Apache Bench:Apache自带服务器压力测试工具

    一个网站或者博客到底能够承受多大的用户访问量经常是我们在用VPS或者独立服务器搭建网站了最关心的问题,还有不少人喜欢对LNMP或者LAMP进行一些优化以便提高Web性能,而优化后到底有多大的效果,就需 ...

  6. Android Studio代码字体模糊解决方法

    问题描述: 我的电脑分辨率是(1920*1080),然而安装了Android Studio后代码的一些部分区域出现模糊的现象,应该是软件默认设置与高分屏有冲突. 如下图所示. 解决方法: 打开设置对话 ...

  7. linux命令(30):touch命令

    实例一:创建不存在的文件 touch test.log test1.log 实例二:更新log.log的时间和log2012.log时间戳相同 touch  -r test.log test1.log ...

  8. mysql大法

    mysql大法 MySQL 安装方式 1.rpm(yum) 2.源码包 3.通用二进制 企业中版本选择 5.6 5.7 选择 GA 6个月到1年之间的------------------------- ...

  9. hihocoder 1135 : Magic Box

    #1135 : Magic Box 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 The circus clown Sunny has a magic box. Whe ...

  10. mysql:视图、触发器、事务、存储、函数、流程控制

    阅读目录 一 视图 二 触发器 三 事务 四 存储过程 五 函数 六 流程控制 回到顶部 一 视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只 ...