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. 我用.htaccess做了些什么?

    1.防图片盗链,减轻流量压力: 2.index.php 301转向到域名,有利于PR权重集中: 3.其它还不会,慢慢来…… 我是如何做的? <IfModule mod_rewrite.c> ...

  2. 【字符串处理算法】字符串包含的算法设计及C代码实现【转】

    转自:http://blog.csdn.net/zhouzhaoxiong1227/article/details/50679587 版权声明:本文为博主原创文章,对文章内容有任何意见或建议,欢迎与作 ...

  3. Linux 入门记录:三、Linux 文件基本操作管理

    一.复制文件.目录 使用 cp 命令复制文件或目录: $ cp 源文件(夹)目标文件(夹) 常用参数: -r 递归复制整个目录树 -v 显示复制过程的详细信息 二.移动.重命名文件或目录 通过 mv  ...

  4. 【LabVIEW技巧】LabVIEW OOP怎么学

    前言 有很多人对LabVIEW OOP存在比较极端的看法,大致分为两类: 1. 绝对否定派认为LabVIEW OOP只不过是LabVIEW为了追求时髦,在面向过程的基础上用簇做了一些特性,实际上完全不 ...

  5. display:inline、block、inline-block三者之间的区别

    1. display:block就是将元素显示为块级元素. block元素的特点: 总是在新行上开始: 高度,行高以及顶和底边距都可控制: 宽度缺省是它的容器的100%,除非设定一个宽度:(<d ...

  6. java中的三元运算符

    格式: 关系表达式 ? 表达式1:表达式2 public class OperatorDemo { public static void main(String[] args){ int a = 10 ...

  7. sublime view_in_browser

    今天安装了sublime的插件view in browser,发现ctrl+alt+V用不了,在preferences看了view in browser的配置,发现browser不是我电脑上的默认浏览 ...

  8. linux命令(48):nl命令

    nl命令在linux系统中用来计算文件中行号.nl 可以将输出的文件内容自动的加上行号!其默认的结果与 cat -n 有点不太一样, nl 可以将行号做比较多的显示设计,包括位数与是否自动补齐 0 等 ...

  9. linux命令(16):mv命令

    移动文件:mv /mnt/test.log /home 移动目录:mv -f /mnt/test /home [带-f参数如目的已存在同名文件,则直接覆盖掉] 文件改名:mv /mnt/test /m ...

  10. Linux非常用命令

    查看系统版本(64位还是32位版本) uname -a 或 more /proc/version 执行结果