text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:134217728")
using namespace std;
long double x, y, z;
string s[] = {"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 a[12];
int main() {
cin >> x >> y >> z;
if (min(z, min(x, y)) > 1) {
a[0] = z * log(y) + log(log(x));
a[1] = y * log(z) + log(log(x));
a[2] = log(y * z) + log(log(x));
a[3] = a[2];
a[4] = z * log(x) + log(log(y));
a[5] = x * log(z) + log(log(y));
a[6] = log(x * z) + log(log(y));
a[7] = a[6];
a[8] = y * log(x) + log(log(z));
a[9] = x * log(y) + log(log(z));
a[10] = log(x * y) + log(log(z));
a[11] = a[10];
} else {
a[0] = pow(y, z) * log(x);
a[1] = pow(z, y) * log(x);
a[2] = y * z * log(x);
a[3] = a[2];
a[4] = pow(x, z) * log(y);
a[5] = pow(z, x) * log(y);
a[6] = x * z * log(y);
a[7] = a[6];
a[8] = pow(x, y) * log(z);
a[9] = pow(y, x) * log(z);
a[10] = x * y * log(z);
a[11] = a[10];
}
long double mx = *max_element(a, a + 12);
for (int i = 0; i < 12; i++) {
if (fabs(mx - a[i]) < 1e-17) {
cout << s[i];
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long double x, y, z;
cin >> x >> y >> z;
const long double eps = (long double)1e-12;
auto check = [&](long double x, long double y) {
return abs(x - y) < eps || abs(x - y) < eps * abs(x);
};
long double logx = log(x);
long double logy = log(y);
long double logz = log(z);
vector<long double> a(11);
a[0] = logx * pow(y, z);
a[1] = logx * pow(z, y);
a[2] = logx * y * z;
a[3] = a[2];
a[4] = logy * pow(x, z);
a[5] = logy * pow(z, x);
a[6] = logy * x * z;
a[7] = a[6];
a[8] = logz * pow(x, y);
a[9] = logz * pow(y, x);
a[10] = logz * x * y;
long double tmp = -1;
int pos = -1;
for (int i = 0; i < 11; i++) {
if (!check(a[i], tmp) && a[i] > tmp) {
tmp = a[i];
pos = i;
}
}
if (pos == 0) {
cout << "x^y^z" << '\n';
} else if (pos == 1) {
cout << "x^z^y" << '\n';
} else if (pos == 2) {
cout << "(x^y)^z" << '\n';
} else if (pos == 4) {
cout << "y^x^z" << '\n';
} else if (pos == 5) {
cout << "y^z^x" << '\n';
} else if (pos == 6) {
cout << "(y^x)^z" << '\n';
} else if (pos == 8) {
cout << "z^x^y" << '\n';
} else if (pos == 9) {
cout << "z^y^x" << '\n';
} else {
cout << "(z^x)^y" << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, maxn = 200005, ln = 17;
const int shift = 30, etf = mod - 1;
const double epcilon = 1e-10;
const long long int inf = (long long int)1e15;
const double PI = (double)3.141592653589793238;
string s[] = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
double a[10], x, y, z;
double pop(double p, double q, double r) {
if (p < 1.0) return -10.0 * inf;
if (p == 1.0) return -1.0 * inf;
return (r * log10(q)) + log10(log10(p));
}
double pom(double p, double q, double r) {
if (p < 1.0) return -10.0 * inf;
if (p == 1.0) return -1.0 * inf;
return (log10(q) + log10(r)) + log10(log10(p));
}
void solve() {
int idx;
double mn = inf;
a[0] = pop(1.0 / x, y, z);
a[1] = pop(1.0 / x, z, y);
a[2] = pom(1.0 / x, y, z);
a[3] = pop(1.0 / y, x, z);
a[4] = pop(1.0 / y, z, x);
a[5] = pom(1.0 / y, x, z);
a[6] = pop(1.0 / z, x, y);
a[7] = pop(1.0 / z, y, x);
a[8] = pom(1.0 / z, x, y);
for (int i = 0; i < 9; i++) {
if (mn - a[i] > epcilon) {
idx = i;
mn = a[i];
}
}
cout << s[idx] << endl;
}
void solve2() {
int idx;
double mx = -100.0 * inf;
a[0] = pop(x, y, z);
a[1] = pop(x, z, y);
a[2] = pom(x, y, z);
a[3] = pop(y, x, z);
a[4] = pop(y, z, x);
a[5] = pom(y, x, z);
a[6] = pop(z, x, y);
a[7] = pop(z, y, x);
a[8] = pom(z, x, y);
for (int i = 0; i < 9; i++) {
if (a[i] - mx > epcilon) {
idx = i;
mx = a[i];
}
}
cout << s[idx] << endl;
}
int main() {
cin >> x >> y >> z;
if (x < 1.0 && y < 1.0 && z < 1.0) {
solve();
return 0;
}
solve2();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
double A[3] = {0};
int id[3] = {0};
bool cmp(int a1, int a2) { return A[a1] < A[a2]; }
const char *ansstr[13] = {
"", "x^y^z", "x^z^y", "(x^y)^z", "", "y^x^z", "y^z^x",
"(y^x)^z", "", "z^x^y", "z^y^x", "(z^x)^y", "",
};
int main() {
cin >> A[0] >> A[1] >> A[2];
id[0] = 0, id[1] = 1, id[2] = 2;
sort(id, id + 3, cmp);
double ans = -1e200;
int ansid = -1;
if (A[id[2]] > 1) {
for (int i = 0; i <= 2; i++) {
double x = A[i];
double y = A[i == 0 ? 1 : 0];
double z = A[i == 2 ? 1 : 2];
if (A[i] > 1) {
double a[5] = {0};
a[1] = log(log(x)) + log(y) * z;
a[2] = log(log(x)) + log(z) * y;
a[3] = log(log(x)) + log(y) + log(z);
for (int j = 1; j <= 3; j++) {
if (a[j] > ans + EPS) {
ans = a[j];
ansid = j + i * 4;
}
}
}
}
} else if (A[id[2]] == 1) {
for (int i = 0; i <= 2; i++) {
if (A[i] == 1) {
ans = 1;
ansid = 1 + i * 4;
break;
}
}
} else {
for (int i = 0; i <= 2; i++) {
double x = A[i];
double y = A[i == 0 ? 1 : 0];
double z = A[i == 2 ? 1 : 2];
double a[5];
a[1] = -log(-log(x)) - log(y) * z;
a[2] = -log(-log(x)) - log(z) * y;
a[3] = -log(-log(x)) - log(y) - log(z);
for (int j = 1; j <= 3; j++) {
if (a[j] > ans + EPS) {
ans = a[j];
ansid = j + i * 4;
}
}
}
}
cout << ansstr[ansid] << endl;
return 0;
}
|
#include <bits/stdc++.h>
const int inf = 1e9 + 5;
const long long linf = 5e18 + 5;
const long double eps = 1e-7;
const int dd = 2e5 + 7;
const int maxn = 2e3 + 10;
const long long mod = 1e9 + 7;
using namespace std;
long double fun(vector<long double> qwe, int k) {
long double x = qwe[0];
long double y = qwe[1];
long double z = qwe[2];
long double ans = 0;
if (k == 0) {
ans = log(x) * pow(y, z);
}
if (k == 1) {
ans = log(x) * pow(z, y);
}
if (k == 2) {
ans = log(x) * y * z;
}
if (k == 3) {
ans = log(x) * y * z;
}
if (k == 4) {
ans = log(y) * pow(x, z);
}
if (k == 5) {
ans = log(y) * pow(z, x);
}
if (k == 6) {
ans = log(y) * x * z;
}
if (k == 7) {
ans = log(y) * x * z;
}
if (k == 8) {
ans = log(z) * pow(x, y);
}
if (k == 9) {
ans = log(z) * pow(y, x);
}
if (k == 10) {
ans = log(z) * x * y;
}
if (k == 11) {
ans = log(z) * x * y;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(0);
if (0) {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
} else {
if (!01) {
freopen(
"sufpref"
".in",
"r", stdin);
freopen(
"sufpref"
".out",
"w", stdout);
}
}
vector<pair<long double, string> > qwe(3);
cin >> qwe[0].first >> qwe[1].first >> qwe[2].first;
qwe[0].second = "x";
qwe[1].second = "y";
qwe[2].second = "z";
vector<long double> zxc;
zxc.push_back(qwe[0].first);
zxc.push_back(qwe[1].first);
zxc.push_back(qwe[2].first);
long double maxx = -linf;
int ind = 0;
for (long long i = 0; i < 12; ++i) {
if (maxx < fun(zxc, i)) maxx = fun(zxc, i), ind = i;
}
map<int, string> asd;
asd[0] = qwe[0].second + "^" + qwe[1].second + "^" + qwe[2].second;
asd[1] = qwe[0].second + "^" + qwe[2].second + "^" + qwe[1].second;
asd[2] =
"(" + qwe[0].second + "^" + qwe[1].second + ")" + "^" + qwe[2].second;
asd[3] =
"(" + qwe[0].second + "^" + qwe[2].second + ")" + "^" + qwe[1].second;
asd[4] = qwe[1].second + "^" + qwe[0].second + "^" + qwe[2].second;
asd[5] = qwe[1].second + "^" + qwe[2].second + "^" + qwe[0].second;
asd[6] =
"(" + qwe[1].second + "^" + qwe[0].second + ")" + "^" + qwe[2].second;
asd[7] =
"(" + qwe[1].second + "^" + qwe[2].second + ")" + "^" + qwe[0].second;
asd[8] = qwe[2].second + "^" + qwe[0].second + "^" + qwe[1].second;
asd[9] = qwe[2].second + "^" + qwe[1].second + "^" + qwe[0].second;
asd[10] =
"(" + qwe[2].second + "^" + qwe[0].second + ")" + "^" + qwe[1].second;
asd[11] =
"(" + qwe[2].second + "^" + qwe[1].second + ")" + "^" + qwe[0].second;
cout << asd[ind];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string v[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"};
pair<long double, long double> sol[12];
const long double EPS = 1e-12;
long double cmp(pair<long double, long double> a,
pair<long double, long double> b) {
long double res1, res2;
res1 = a.second * log(a.first);
res2 = b.second * log(b.first);
if (abs(res1 - res2) < EPS) return 0;
return res1 - res2;
}
int main() {
int i, pos;
long double x, y, z;
cin >> x >> y >> z;
sol[0] = {x, pow(y, z)};
sol[1] = {x, pow(z, y)};
sol[2] = {x, y * z};
sol[3] = {x, z * y};
sol[4] = {y, pow(x, z)};
sol[5] = {y, pow(z, x)};
sol[6] = {y, x * z};
sol[6] = {y, z * x};
sol[8] = {z, pow(x, y)};
sol[9] = {z, pow(y, x)};
sol[10] = {z, x * y};
sol[11] = {z, y * x};
pos = 0;
for (i = 1; i < 12; ++i) {
if (cmp(sol[pos], sol[i]) < 0) pos = i;
}
cout << v[pos];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
long double x, y, z, a[13], mx;
string s[13] = {"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"};
int ind = 0;
cin >> x >> y >> z;
a[0] = pow(y, z) * log(x);
mx = a[0];
a[1] = pow(z, y) * log(x);
a[2] = z * y * log(x);
a[3] = z * y * log(x);
a[4] = pow(x, z) * log(y);
a[5] = pow(z, x) * log(y);
a[6] = z * x * log(y);
a[7] = z * x * log(y);
a[8] = pow(x, y) * log(z);
a[9] = pow(y, x) * log(z);
a[10] = y * x * log(z);
a[11] = y * x * log(z);
for (int i = 0; i < 12; i++) {
if (mx + 1e-15 < a[i]) {
mx = a[i];
ind = i;
}
}
cout << s[ind] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool bigger(complex<long double> a, complex<long double> b) {
if (imag(a) == 0 && imag(b) == 0) {
return real(a) > real(b);
} else if (imag(a) == 0 && imag(b) != 0) {
return true;
} else if (imag(a) != 0 && imag(b) == 0) {
return false;
} else if (imag(a) != 0 && imag(b) != 0) {
return real(a) < real(b);
}
}
int main() {
long double ax, ay, az;
cin >> ax >> ay >> az;
complex<long double> x(ax, 0.0L);
complex<long double> y(ay, 0.0L);
complex<long double> z(az, 0.0L);
complex<long double> cmaz(3, 3);
string ans = "xd";
if (bigger(z * log(y) + log(log(x)), cmaz)) {
cmaz = z * log(y) + log(log(x));
ans = "x^y^z";
}
if (bigger(y * log(z) + log(log(x)), cmaz)) {
cmaz = y * log(z) + log(log(x));
ans = "x^z^y";
}
if (bigger(log(y * z) + log(log(x)), cmaz)) {
cmaz = log(y * z) + log(log(x));
ans = "(x^y)^z";
}
if (bigger(z * log(x) + log(log(y)), cmaz)) {
cmaz = z * log(x) + log(log(y));
ans = "y^x^z";
}
if (bigger(x * log(z) + log(log(y)), cmaz)) {
cmaz = x * log(z) + log(log(y));
ans = "y^z^x";
}
if (bigger(log(x * z) + log(log(y)), cmaz)) {
cmaz = log(x * z) + log(log(y));
ans = "(y^x)^z";
}
if (bigger(y * log(x) + log(log(z)), cmaz)) {
cmaz = y * log(x) + log(log(z));
ans = "z^x^y";
}
if (bigger(x * log(y) + log(log(z)), cmaz)) {
cmaz = x * log(y) + log(log(z));
ans = "z^y^x";
}
if (bigger(log(x * y) + log(log(z)), cmaz)) {
cmaz = log(x * y) + log(log(z));
ans = "(z^x)^y";
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const double inf = 100000000000000000;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 10;
const int maxv = 1e3 + 10;
const double eps = 1e-9;
int ju = 0;
double f22(double a, double b) {
if (ju) a = 1.0 / a;
if (a > 1.0 - eps) return log(log(a)) + log(b);
return -inf;
}
double f33(double a, double b, double c) {
if (ju) a = 1.0 / a;
if (a > 1.0 - eps) return log(log(a)) + c * log(b);
return -inf;
}
double f1(double a, double b, double c) { return f33(a, b, c); }
double f2(double a, double b, double c) { return f33(a, c, b); }
double f3(double a, double b, double c) { return f22(a, b * c); }
double f4(double a, double b, double c) { return f22(a, b * c); }
double f5(double a, double b, double c) { return f33(b, a, c); }
double f6(double a, double b, double c) { return f33(b, c, a); }
double f7(double a, double b, double c) { return f22(b, a * c); }
double f8(double a, double b, double c) { return f22(b, a * c); }
double f9(double a, double b, double c) { return f33(c, a, b); }
double f10(double a, double b, double c) { return f33(c, b, a); }
double f11(double a, double b, double c) { return f22(c, a * b); }
double f12(double a, double b, double c) { return f22(c, a * b); }
bool judge(double l, double r, int ju) {
if (ju) return l > r + eps;
return l < r - eps;
}
int main() {
double x, y, c;
while (scanf("%lf%lf%lf", &x, &y, &c) != EOF) {
ju = 0;
if (x < 1.0 + eps && y < 1.0 + eps && c < 1.0 + eps) {
ju = 1;
}
double res = 0;
int id = 0;
res = f1(x, y, c);
id = 1;
if (judge(res, f2(x, y, c), ju)) {
res = f2(x, y, c);
id = 2;
}
if (judge(res, f3(x, y, c), ju)) {
res = f3(x, y, c);
id = 3;
}
if (judge(res, f4(x, y, c), ju)) {
res = f4(x, y, c);
id = 4;
}
if (judge(res, f5(x, y, c), ju)) {
res = f5(x, y, c);
id = 5;
}
if (judge(res, f6(x, y, c), ju)) {
res = f6(x, y, c);
id = 6;
}
if (judge(res, f7(x, y, c), ju)) {
res = f7(x, y, c);
id = 7;
}
if (judge(res, f8(x, y, c), ju)) {
res = f8(x, y, c);
id = 8;
}
if (judge(res, f9(x, y, c), ju)) {
res = f9(x, y, c);
id = 9;
}
if (judge(res, f10(x, y, c), ju)) {
res = f10(x, y, c);
id = 10;
}
if (judge(res, f11(x, y, c), ju)) {
res = f11(x, y, c);
id = 11;
}
if (judge(res, f12(x, y, c), ju)) {
res = f12(x, y, c);
id = 12;
}
if (id == 1)
puts("x^y^z");
else if (id == 2)
puts("x^z^y");
else if (id == 3)
puts("(x^y)^z");
else if (id == 4)
puts("(x^z)^y");
else if (id == 5)
puts("y^x^z");
else if (id == 6)
puts("y^z^x");
else if (id == 7)
puts("(y^x)^z");
else if (id == 8)
puts("(y^z)^x");
else if (id == 9)
puts("z^x^y");
else if (id == 10)
puts("z^y^x");
else if (id == 11)
puts("(z^x)^y");
else
puts("(z^y)^x");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool compare(complex<long double> a, complex<long double> b) {
if (imag(a) == 0 and imag(b) == 0)
return real(a) > real(b);
else if (imag(a) == 0 and imag(b) != 0)
return true;
else if (imag(a) != 0 and imag(b) == 0)
return false;
else if (imag(a) != 0 and imag(b) != 0)
return real(a) < real(b);
}
complex<long double> eval(string exp, complex<long double>* inp) {
if (exp.size() == 5) {
complex<long double> x = inp[exp[0] - 'x'], y = inp[exp[2] - 'x'],
z = inp[exp[4] - 'x'];
return z * log(y) + log(log(x));
} else {
complex<long double> x = inp[exp[1] - 'x'], y = inp[exp[3] - 'x'],
z = inp[exp[6] - 'x'];
return log(y * z) + log(log(x));
}
}
int main() {
long double x1, y1, z1;
cin >> x1 >> y1 >> z1;
string exp[9] = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
int ans = -1;
complex<long double> temp;
complex<long double> inp[3] = {complex<long double>(x1, 0),
complex<long double>(y1, 0),
complex<long double>(z1, 0)};
for (int i = 0; i < 9; i++) {
if (ans == -1) {
temp = eval(exp[i], inp);
ans = i;
} else if (compare(eval(exp[i], inp), temp)) {
temp = eval(exp[i], inp);
ans = i;
}
}
cout << exp[ans] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
double eps = 1e-12;
int idx(-1);
double m(-1e18), cur;
double a, b, c, xy, yz, zx, yx, zy, xz;
void f1() {
cur = yz + log(a);
if (cur > m + eps) {
m = cur;
idx = 0;
}
cur = zy + log(a);
if (cur > m + eps) {
m = cur;
idx = 1;
}
cur = c + log(xy);
if (cur > m + eps) {
m = cur;
idx = 2;
}
cur = b + log(xz);
if (cur > m + eps) {
m = cur;
idx = 3;
}
}
void f2() {
cur = xz + log(b);
if (cur > m + eps) {
m = cur;
idx = 4;
}
cur = zx + log(b);
if (cur > m + eps) {
m = cur;
idx = 5;
}
cur = c + log(yx);
if (cur > m + eps) {
m = cur;
idx = 6;
}
cur = a + log(yz);
if (cur > m + eps) {
m = cur;
idx = 7;
}
}
void f3() {
cur = xy + log(c);
if (cur > m + eps) {
m = cur;
idx = 8;
}
cur = yx + log(c);
if (cur > m + eps) {
m = cur;
idx = 9;
}
cur = b + log(zx);
if (cur > m + eps) {
m = cur;
idx = 10;
}
cur = a + log(zy);
if (cur > m + eps) {
m = cur;
idx = 11;
}
}
int main() {
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"};
double x, y, z;
cin >> x >> y >> z;
a = log(x), b = log(y), c = log(z);
xy = y * log(x), yz = z * log(y), zx = x * log(z);
yx = x * log(y), zy = y * log(z), xz = z * log(x);
if (x > 1.05 && y > 1.05 && z > 1.05)
f1(), f2(), f3();
else if (x > 1.05 && y > 1.05)
f1(), f2();
else if (y > 1.05 && z > 1.05)
f2(), f3();
else if (x > 1.05 && z > 1.05)
f1(), f3();
else if (x > 1.05)
f1();
else if (y > 1.05)
f2();
else if (z > 1.05)
f3();
else {
cur = pow(x, pow(y, z));
if (cur > m + eps) {
m = cur;
idx = 0;
}
cur = pow(x, pow(z, y));
if (cur > m + eps) {
m = cur;
idx = 1;
}
cur = pow(pow(x, y), z);
if (cur > m + eps) {
m = cur;
idx = 2;
}
cur = pow(pow(x, z), y);
if (cur > m + eps) {
m = cur;
idx = 3;
}
cur = pow(y, pow(x, z));
if (cur > m + eps) {
m = cur;
idx = 4;
}
cur = pow(y, pow(z, x));
if (cur > m + eps) {
m = cur;
idx = 5;
}
cur = pow(pow(y, x), z);
if (cur > m + eps) {
m = cur;
idx = 6;
}
cur = pow(pow(y, z), x);
if (cur > m + eps) {
m = cur;
idx = 7;
}
cur = pow(z, pow(x, y));
if (cur > m + eps) {
m = cur;
idx = 8;
}
cur = pow(z, pow(y, x));
if (cur > m + eps) {
m = cur;
idx = 9;
}
cur = pow(pow(z, x), y);
if (cur > m + eps) {
m = cur;
idx = 10;
}
cur = pow(pow(z, y), x);
if (cur > m + eps) {
m = cur;
idx = 11;
}
}
cout << s[idx];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using PII = pair<int, int>;
using LD = long double;
vector<string> rasp = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
LD answer = -2, x, y, z;
string str;
void ch(LD &ret1, LD &toCh, string C) {
if (ret1 - toCh > 0.0001) toCh = ret1, str = C;
}
void solve(LD x, LD y, LD z, int code) {
vector<LD> arr = {log(x) * pow(y, z), log(x) * pow(z, y), log(x) * y * z};
for (auto &cur : arr) ch(cur, answer, rasp[code + (&cur - &arr[0])]);
}
int main() {
cin >> x >> y >> z;
solve(x, y, z, 0);
solve(y, x, z, 3);
solve(z, x, y, 6);
cout << str;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
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 x, y, z, a[12], mx;
int i, k;
cin >> x >> y >> z;
a[0] = pow(y, z) * log(x);
a[1] = pow(z, y) * log(x);
a[2] = a[3] = z * y * 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[10] = a[11] = x * y * log(z);
mx = a[0];
k = 0;
for (i = 1; i < 12; i++)
if (a[i] > mx) {
mx = a[i];
k = i;
}
cout << s[k] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
double x, y, z;
string b[15];
void Pre() {
b[1] = "x^y^z";
b[2] = "x^z^y";
b[3] = "(x^y)^z";
b[4] = "(x^z)^y";
b[5] = "y^x^z";
b[6] = "y^z^x";
b[7] = "(y^x)^z";
b[8] = "(y^z)^x";
b[9] = "z^x^y";
b[10] = "z^y^x";
b[11] = "(z^x)^y";
b[12] = "(z^y)^x";
}
void solve() {
vector<pair<double, int> > res;
if (x < 1 && y < 1 && z < 1) {
res.push_back(make_pair(pow(y, z) * log(x), 1));
res.push_back(make_pair(pow(z, y) * log(x), 2));
res.push_back(make_pair(y * z * log(x), 3));
res.push_back(make_pair(y * z * log(x), 4));
res.push_back(make_pair(pow(x, z) * log(y), 5));
res.push_back(make_pair(pow(z, x) * log(y), 6));
res.push_back(make_pair(x * z * log(y), 7));
res.push_back(make_pair(x * z * log(y), 8));
res.push_back(make_pair(pow(x, y) * log(z), 9));
res.push_back(make_pair(pow(y, x) * log(z), 10));
res.push_back(make_pair(y * x * log(z), 11));
res.push_back(make_pair(y * x * log(z), 12));
} else {
if (x >= 1) res.push_back(make_pair(z * log(y) + log(log(x)), 1));
if (x >= 1) res.push_back(make_pair(y * log(z) + log(log(x)), 2));
if (x >= 1) res.push_back(make_pair(log(y) + log(z) + log(log(x)), 3));
if (x >= 1) res.push_back(make_pair(log(y) + log(z) + log(log(x)), 4));
if (y >= 1) res.push_back(make_pair(z * log(x) + log(log(y)), 5));
if (y >= 1) res.push_back(make_pair(x * log(z) + log(log(y)), 6));
if (y >= 1) res.push_back(make_pair(log(x) + log(z) + log(log(y)), 7));
if (y >= 1) res.push_back(make_pair(log(x) + log(z) + log(log(y)), 8));
if (z >= 1) res.push_back(make_pair(y * log(x) + log(log(z)), 9));
if (z >= 1) res.push_back(make_pair(x * log(y) + log(log(z)), 10));
if (z >= 1) res.push_back(make_pair(log(y) + log(x) + log(log(z)), 11));
if (z >= 1) res.push_back(make_pair(log(y) + log(x) + log(log(z)), 12));
}
sort(res.begin(), res.end());
int id = res[res.size() - 1].second;
double maxx = res[res.size() - 1].first;
for (int i = 0; i < res.size(); i++) {
if (res[i].first == maxx) {
id = min(id, res[i].second);
}
}
printf("%s\n", b[id].c_str());
}
int main() {
while (scanf("%lf %lf %lf", &x, &y, &z) != EOF) {
Pre();
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)(1e9);
const long long INF64 = (long long)(1e18);
const long double EPS = 1e-9;
const long double PI = 3.1415926535897932384626433832795;
int main() {
double x, y, z;
cin >> x >> y >> z;
string arr[13];
arr[1] = "x^y^z";
arr[2] = "x^z^y";
arr[3] = "(x^y)^z";
arr[4] = "(x^z)^y";
arr[5] = "y^x^z";
arr[6] = "y^z^x";
arr[7] = "(y^x)^z";
arr[8] = "(y^z)^x";
arr[9] = "z^x^y";
arr[10] = "z^y^x";
arr[11] = "(z^x)^y";
arr[12] = "(z^y)^x";
if (x > 1 && y > 1 && z > 1) {
double res[13];
res[1] = z * log(y) + log(log(x));
res[2] = y * log(z) + log(log(x));
res[3] = log(z) + log(y) + log(log(x));
res[4] = log(y) + log(z) + log(log(x));
res[5] = z * log(x) + log(log(y));
res[6] = x * log(z) + log(log(y));
res[7] = log(z) + log(x) + log(log(y));
res[8] = log(x) + log(z) + log(log(y));
res[9] = y * log(x) + log(log(z));
res[10] = x * log(y) + log(log(z));
res[11] = log(y) + log(x) + log(log(z));
res[12] = log(x) + log(y) + log(log(z));
double ans = -INF64 * 1.0;
int pos;
for (int i = 1; i <= 12; ++i) {
if ((res[i] - ans) > EPS) {
ans = res[i];
pos = i;
}
}
cout << arr[pos] << endl;
} else if (x <= 1 && y <= 1 && z <= 1) {
double res[13];
res[1] = pow(x, pow(y, z));
res[2] = pow(x, pow(z, y));
res[3] = pow(pow(x, y), z);
res[4] = pow(pow(x, z), y);
res[5] = pow(y, pow(x, z));
res[6] = pow(y, pow(z, x));
res[7] = pow(pow(y, x), z);
res[8] = pow(pow(y, z), x);
res[9] = pow(z, pow(x, y));
res[10] = pow(z, pow(y, x));
res[11] = pow(pow(z, x), y);
res[12] = pow(pow(z, y), x);
double ans = -INF64 * 1.0;
int pos;
for (int i = 1; i <= 12; ++i) {
if ((res[i] - ans) > EPS) {
pos = i;
ans = res[i];
}
}
cout << arr[pos] << endl;
} else {
double ans = -INF64;
int pos;
double res[13];
if (x > 1) {
res[1] = z * log(y) + log(log(x));
res[2] = y * log(z) + log(log(x));
res[3] = log(z) + log(y * log(x));
res[4] = log(y) + log(z * log(x));
for (int i = 1; i <= 4; ++i) {
if ((res[i] - ans) > EPS) {
ans = res[i];
pos = i;
}
}
}
if (y > 1) {
res[5] = z * log(x) + log(log(y));
res[6] = x * log(z) + log(log(y));
res[7] = log(z) + log(x * log(y));
res[8] = log(x) + log(z * log(y));
for (int i = 5; i <= 8; ++i) {
if ((res[i] - ans) > EPS) {
ans = res[i];
pos = i;
}
}
}
if (z > 1) {
res[9] = y * log(x) + log(log(z));
res[10] = x * log(y) + log(log(z));
res[11] = log(y) + log(x * log(z));
res[12] = log(x) + log(y * log(z));
for (int i = 9; i <= 12; ++i) {
if ((res[i] - ans) > EPS) {
ans = res[i];
pos = i;
}
}
}
cout << arr[pos] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
char *s[9] = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
double sx, sy, sz;
long double x, y, z;
std::vector<long double> a;
int main() {
scanf("%lf%lf%lf", &sx, &sy, &sz);
x = sx;
y = sy;
z = sz;
a = {logl(x) * powl(y, z), logl(x) * powl(z, y), logl(x) * y * z,
logl(y) * powl(x, z), logl(y) * powl(z, x), logl(y) * x * z,
logl(z) * powl(x, y), logl(z) * powl(y, x), logl(z) * x * y};
printf("%s\n", s[max_element(a.begin(), a.end()) - a.begin()]);
return 0;
}
|
#include <bits/stdc++.h>
int c = 1;
double x, y, z, a[20];
char b[20][20];
double lg(double x) {
if (x < 0)
return -2e9;
else
return log(x);
}
int main() {
scanf("%lf %lf %lf", &x, &y, &z);
strcpy(b[1], "x^y^z");
strcpy(b[2], "x^z^y");
strcpy(b[3], "(x^y)^z");
strcpy(b[4], "(x^z)^y");
strcpy(b[5], "y^x^z");
strcpy(b[6], "y^z^x");
strcpy(b[7], "(y^x)^z");
strcpy(b[8], "(y^z)^x");
strcpy(b[9], "z^x^y");
strcpy(b[10], "z^y^x");
strcpy(b[11], "(z^x)^y");
strcpy(b[12], "(z^y)^x");
if (x <= 1 && y <= 1 && z <= 1) {
a[1] = pow(x, pow(y, z));
a[2] = pow(x, pow(z, y));
a[3] = pow(x, y * z);
a[4] = pow(x, z * y);
a[5] = pow(y, pow(x, z));
a[6] = pow(y, pow(z, x));
a[7] = pow(y, x * z);
a[8] = pow(y, z * x);
a[9] = pow(z, pow(x, y));
a[10] = pow(z, pow(y, x));
a[11] = pow(z, x * y);
a[12] = pow(z, y * x);
} else {
a[1] = z * lg(y) + lg(lg(x));
a[2] = y * lg(z) + lg(lg(x));
a[3] = lg(y * z) + lg(lg(x));
a[4] = lg(z * y) + lg(lg(x));
a[5] = z * lg(x) + lg(lg(y));
a[6] = x * lg(z) + lg(lg(y));
a[7] = lg(x * z) + lg(lg(y));
a[8] = lg(z * x) + lg(lg(y));
a[9] = y * lg(x) + lg(lg(z));
a[10] = x * lg(y) + lg(lg(z));
a[11] = lg(x * y) + lg(lg(z));
a[12] = lg(y * x) + lg(lg(z));
}
for (int i = 2; i <= 12; i++)
if (a[i] > a[c]) c = i;
printf("%s\n", b[c]);
scanf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-12;
long double ans[15];
string Ans[] = {"", "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"};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
long double aa, bb, cc;
cin >> aa >> bb >> cc;
long double x = aa, y = bb, z = cc;
int i;
long double lx = log(x);
long double ly = log(y);
long double lz = log(z);
if (x + eps < 1.0 || y + eps < 1.0 || z + eps < 1.0) {
ans[1] = lx * pow(y, z);
ans[2] = lx * pow(z, y);
ans[3] = lx * y * z;
ans[4] = lx * z * y;
ans[5] = ly * pow(x, z);
ans[6] = ly * pow(z, x);
ans[7] = ly * x * z;
ans[8] = ly * x * z;
ans[9] = lz * pow(x, y);
ans[10] = lz * pow(y, x);
ans[11] = lz * x * y;
ans[12] = lz * x * y;
} else {
ans[1] = z * log(y) + log(log(x));
ans[2] = y * log(z) + log(log(x));
ans[3] = log(z * y * log(x));
ans[4] = log(z * y * log(x));
ans[5] = z * log(x) + log(log(y));
ans[6] = x * log(z) + log(log(y));
ans[7] = log(x * z * log(y));
ans[8] = log(x * z * log(y));
ans[9] = y * log(x) + log(log(z));
ans[10] = x * log(y) + log(log(z));
ans[11] = log(x * y * log(z));
ans[12] = log(x * y * log(z));
}
double k = ans[1];
int si = 1;
for (i = 2; i <= 12; i++)
if (ans[i] > k + eps) {
k = ans[i];
si = i;
}
cout << Ans[si] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 10000005;
int main() {
long double x, y, z, maxvalue, minindex;
cin >> x >> y >> z;
maxvalue = x * y * log(z);
minindex = 11;
if (pow(y, x) * log(z) >= maxvalue) {
maxvalue = pow(y, x) * log(z);
minindex = 10;
}
if (pow(x, y) * log(z) >= maxvalue) {
maxvalue = pow(x, y) * log(z);
minindex = 9;
}
if (x * z * log(y) >= maxvalue) {
maxvalue = x * z * log(y);
minindex = 7;
}
if (pow(z, x) * log(y) >= maxvalue) {
maxvalue = pow(z, x) * log(y);
minindex = 6;
}
if (pow(x, z) * log(y) >= maxvalue) {
maxvalue = pow(x, z) * log(y);
minindex = 5;
}
if (y * z * log(x) >= maxvalue) {
maxvalue = y * z * log(x);
minindex = 3;
}
if (pow(z, y) * log(x) >= maxvalue) {
maxvalue = pow(z, y) * log(x);
minindex = 2;
}
if (pow(y, z) * log(x) >= maxvalue) {
maxvalue = pow(y, z) * log(x);
minindex = 1;
}
if (minindex == 11) cout << "(z^x)^y";
if (minindex == 10) cout << "z^y^x";
if (minindex == 9) cout << "z^x^y";
if (minindex == 7) cout << "(y^x)^z";
if (minindex == 6) cout << "y^z^x";
if (minindex == 5) cout << "y^x^z";
if (minindex == 3) cout << "(x^y)^z";
if (minindex == 2) cout << "x^z^y";
if (minindex == 1) cout << "x^y^z";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1.01e9;
const long double eps = 1e-16;
int main() {
string best = "";
long double res = -1e300;
long double x, y, z;
double xx, yy, zz;
scanf("%lf%lf%lf", &xx, &yy, &zz);
x = xx, y = yy, z = zz;
long double val;
val = logl(x) * powl(y, z);
if (val > res + abs(res) * eps) res = val, best = "x^y^z";
val = logl(x) * powl(z, y);
if (val > res + abs(res) * eps) res = val, best = "x^z^y";
val = logl(x) * y * z;
if (val > res + abs(res) * eps) res = val, best = "(x^y)^z";
val = logl(y) * powl(x, z);
if (val > res + abs(res) * eps) res = val, best = "y^x^z";
val = logl(y) * powl(z, x);
if (val > res + abs(res) * eps) res = val, best = "y^z^x";
val = logl(y) * x * z;
if (val > res + abs(res) * eps) res = val, best = "(y^x)^z";
val = logl(z) * powl(x, y);
if (val > res + abs(res) * eps) res = val, best = "z^x^y";
val = logl(z) * powl(y, x);
if (val > res + abs(res) * eps) res = val, best = "z^y^x";
val = logl(z) * x * y;
if (val > res + abs(res) * eps) res = val, best = "(z^x)^y";
printf("%s\n", best.data());
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool mm[14];
long double a[14];
int main() {
long double x, y, z, mx = -1e20;
cin >> x >> y >> z;
int ans = 0;
{
a[1] = z * log(y) + log(abs(log(x)));
if (log(x) < 0) mm[1] = 1;
}
{
a[2] = y * log(z) + log(abs(log(x)));
if (log(x) < 0) mm[2] = 1;
}
{
a[3] = log(y * z * abs(log(x)));
if (y * z * log(x) < 0) mm[3] = 1;
}
{
a[5] = z * log(x) + log(abs(log(y)));
if (log(y) < 0) mm[5] = 1;
}
{
a[6] = x * log(z) + log(abs(log(y)));
if (log(y) < 0) mm[6] = 1;
}
{
a[7] = log(x * z * abs(log(y)));
if (x * z * log(y) < 0) mm[7] = 1;
}
{
a[9] = y * log(x) + log(abs(log(z)));
if (log(z) < 0) mm[9] = 1;
}
{
a[10] = x * log(y) + log(abs(log(z)));
if (log(z) < 0) mm[10] = 1;
}
{
a[11] = log(x * y * abs(log(z)));
if (x * y * log(z) < 0) mm[11] = 1;
}
for (int i = 1; i <= 12; ++i) {
if (i % 4 == 0) continue;
if (mm[i]) continue;
if (a[i] - 1e-8 > mx) {
mx = a[i];
ans = i;
}
}
if (!ans) {
mx = 1e20;
for (int i = 1; i <= 12; ++i) {
if (i % 4 == 0) continue;
if (a[i] + 1e-8 < mx) {
mx = a[i];
ans = i;
}
}
}
switch (ans) {
case 1:
cout << "x^y^z" << endl;
break;
;
case 2:
cout << "x^z^y" << endl;
break;
;
case 3:
cout << "(x^y)^z" << endl;
break;
;
case 5:
cout << "y^x^z" << endl;
break;
;
case 6:
cout << "y^z^x" << endl;
break;
;
case 7:
cout << "(y^x)^z" << endl;
break;
;
case 9:
cout << "z^x^y" << endl;
break;
;
case 10:
cout << "z^y^x" << endl;
break;
;
case 11:
cout << "(z^x)^y" << endl;
break;
;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100010;
const long double eps = 1e-10;
long double a[Maxn], b[Maxn];
long double x, y, z;
const char* result[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"};
int main() {
cin >> x >> y >> z;
a[0] = z * log(y);
a[1] = y * log(z);
a[2] = a[3] = log(y) + log(z);
a[4] = z * log(x);
a[5] = x * log(z);
a[6] = a[7] = log(x) + log(z);
a[8] = y * log(x);
a[9] = x * log(y);
a[10] = a[11] = log(x) + log(y);
b[0] = b[1] = b[2] = b[3] = log(x);
b[4] = b[5] = b[6] = b[7] = log(y);
b[8] = b[9] = b[10] = b[11] = log(z);
bool flag = false;
for (int i = 0; i < 12; i++) flag |= (b[i] > 0);
if (flag) {
int pos = 0;
for (int i = 0; i < 12; i++)
if (b[i] > 0) {
pos = i;
break;
}
for (int i = 0; i < 12; i++)
if (b[i] > 0) {
if (a[i] + log(b[i]) > a[pos] + log(b[pos]) + eps) pos = i;
}
printf("%s\n", result[pos]);
} else {
int pos = 0;
for (int i = 0; i < 12; i++) b[i] *= -1.0;
for (int i = 0; i < 12; i++) {
if (a[i] + log(b[i]) + eps < a[pos] + log(b[pos])) pos = i;
}
printf("%s\n", result[pos]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long double x, y, z, res = -1.0;
string str;
cin >> x >> y >> z;
if (pow(y, z) * log10(x) > res) {
str = "x^y^z";
res = pow(y, z) * log10(x);
}
if (pow(z, y) * log10(x) > res) {
str = "x^z^y";
res = pow(z, y) * log10(x);
}
if (pow(x, z) * log10(y) > res) {
str = "y^x^z";
res = pow(x, z) * log10(y);
}
if (pow(z, x) * log10(y) > res) {
str = "y^z^x";
res = pow(z, x) * log10(y);
}
if (pow(x, y) * log10(z) > res) {
str = "z^x^y";
res = pow(x, y) * log10(z);
}
if (pow(y, x) * log10(z) > res) {
str = "z^y^x";
res = pow(y, x) * log10(z);
}
if (y * z * log10(x) > res) {
str = "(x^y)^z";
res = y * z * log10(x);
}
if (x * z * log10(y) > res) {
str = "(y^x)^z";
res = x * z * log10(y);
}
if (y * x * log10(z) > res) {
str = "(z^x)^y";
}
cout << str << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void sc(int& a) { scanf("%d", &a); }
void sc(long long int& a) { scanf("%lld", &a); }
void sc(int& a, int& b) {
sc(a);
sc(b);
}
void sc(long long int& a, long long int& b) {
sc(a);
sc(b);
}
void sc(int& a, int& b, int& c) {
sc(a, b);
sc(c);
}
void sc(long long int& a, long long int& b, long long int& c) {
sc(a, b);
sc(c);
}
void prl(int a) { printf("%d\n", a); }
void prl(long long int a) { printf("%lld\n", a); }
void prl() { printf("\n"); }
void prs(int a) { printf("%d ", a); }
void prs(long long int a) { printf("%lld ", a); }
void prl(long long int a, long long int b, long long int c = -1,
long long int d = -1, long long int e = -1, long long int f = -1) {
cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;
}
int mod = 1000000007;
long long int modpow(long long int a, long long int b, long long int mod) {
long long int res = 1;
while (b > 0) {
if (b & 1) res = (res * a) % mod;
a = (a * a) % mod;
b = b / 2;
}
return res % mod;
}
long long int pow(long long int a, long long int b) {
long long int res = 1;
while (b > 0) {
if (b & 1) res = (res * a);
a = (a * a);
b = b / 2;
}
return res;
}
bool comp(pair<double, int> x, pair<double, int> y) {
if (x.first != y.first) return x.first > y.first;
return x.second < y.second;
}
map<int, string> mp;
int main() {
mp[1] = "x^y^z";
mp[2] = "x^z^y";
mp[3] = "(x^y)^z";
mp[4] = "(x^z)^y";
mp[5] = "y^x^z";
mp[6] = "y^z^x";
mp[7] = "(y^x)^z";
mp[8] = "(y^z)^x";
mp[9] = "z^x^y";
mp[10] = "z^y^x";
mp[11] = "(z^x)^y";
mp[12] = "(z^y)^x";
double x, y, z;
cin >> x >> y >> z;
int ans = 0;
vector<pair<double, int> > t;
if (x <= 1 and y <= 1 and z <= 1) {
t.push_back(make_pair(pow(x, pow(y, z)), 1));
t.push_back(make_pair(pow(x, pow(z, y)), 2));
t.push_back(make_pair(pow(x, y * z), 3));
t.push_back(make_pair(pow(y, pow(x, z)), 5));
t.push_back(make_pair(pow(y, pow(z, x)), 6));
t.push_back(make_pair(pow(y, x * z), 7));
t.push_back(make_pair(pow(z, pow(x, y)), 9));
t.push_back(make_pair(pow(z, pow(y, x)), 10));
t.push_back(make_pair(pow(z, x * y), 11));
} else {
double logx = log(x), logy = log(y), logz = log(z);
if (x > 1) {
t.push_back(make_pair(z * logy + log(logx), 1));
t.push_back(make_pair(y * logz + log(logx), 2));
t.push_back(make_pair(log(y * z * logx), 3));
}
if (y > 1) {
t.push_back(make_pair(z * logx + log(logy), 5));
t.push_back(make_pair(x * logz + log(logy), 6));
t.push_back(make_pair(log(x * z * logy), 7));
}
if (z > 1) {
t.push_back(make_pair(y * logx + log(logz), 9));
t.push_back(make_pair(x * logy + log(logz), 10));
t.push_back(make_pair(log(x * y * logz), 11));
}
}
sort(t.begin(), t.end(), comp);
ans = t[0].second;
cout << mp[ans] << endl;
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const double eps = 1e-7;
const double pi = acos(-1.0);
const long long INF = (long long)2e9 + 1;
const long long LINF = (long long)8e18;
const long long inf = (long long)2e9 + 1;
const long long linf = (long long)8e18;
const long long MM = (long long)1e9 + 7;
int solve();
void gen();
int main() {
solve();
return 0;
}
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"};
int solve() {
long double x, y, z;
cin >> x >> y >> z;
vector<long double> a(12);
a[0] = pow(y, z) * log(x);
a[1] = pow(z, y) * log(x);
a[2] = y * z * log(x);
a[3] = a[2];
a[4] = pow(x, z) * log(y);
a[5] = pow(z, x) * log(y);
a[6] = z * x * log(y);
a[7] = a[6];
a[8] = pow(x, y) * log(z);
a[9] = pow(y, x) * log(z);
a[10] = x * y * log(z);
a[11] = a[10];
long double maxi = a[0];
for (int i = 0; i < 12; ++i) {
if (abs(a[i] - maxi) > eps) {
maxi = max(maxi, a[i]);
}
}
int ans = 0;
for (int i = 0; i < (int)12; i++) {
if (abs(a[i] - maxi) < eps) {
ans = i;
break;
}
}
cout << s[ans];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long double x, y, z;
cin >> x >> y >> z;
long double res = log(x) * pow(y, z);
int out = 1;
if (log(x) * pow(z, y) > res) out = 2, res = log(x) * pow(z, y);
if (log(x) * z * y > res) out = 3, res = log(x) * z * y;
if (log(y) * pow(x, z) > res) out = 5, res = log(y) * pow(x, z);
if (log(y) * pow(z, x) > res) out = 6, res = log(y) * pow(z, x);
if (log(y) * x * z > res) out = 7, res = log(y) * x * z;
if (log(z) * pow(x, y) > res) out = 9, res = log(z) * pow(x, y);
if (log(z) * pow(y, x) > res) out = 10, res = log(z) * pow(y, x);
if (log(z) * x * y > res) out = 11;
if (out == 1) puts("x^y^z");
if (out == 2) puts("x^z^y");
if (out == 3) puts("(x^y)^z");
if (out == 5) puts("y^x^z");
if (out == 6) puts("y^z^x");
if (out == 7) puts("(y^x)^z");
if (out == 9) puts("z^x^y");
if (out == 10) puts("z^y^x");
if (out == 11) puts("(z^x)^y");
}
|
#include <bits/stdc++.h>
using namespace std;
long double x, y, z;
string ans = "x^y^z";
int main() {
cin >> x >> y >> z;
long double res = log(x) * pow(y, z);
long double res1 = log(x) * pow(z, y);
if (res1 > res) {
res = res1;
ans = "x^z^y";
}
res1 = log(x) * y * z;
if (res1 > res) {
res = res1;
ans = "(x^y)^z";
}
res1 = log(y) * pow(x, z);
if (res1 > res) {
res = res1;
ans = "y^x^z";
}
res1 = log(y) * pow(z, x);
if (res1 > res) {
res = res1;
ans = "y^z^x";
}
res1 = log(y) * x * z;
if (res1 > res) {
res = res1;
ans = "(y^x)^z";
}
res1 = log(z) * pow(x, y);
if (res1 > res) {
res = res1;
ans = "z^x^y";
}
res1 = log(z) * pow(y, x);
if (res1 > res) {
res = res1;
ans = "z^y^x";
}
res1 = log(z) * x * y;
if (res1 > res) {
res = res1;
ans = "(z^x)^y";
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
char out[12][15] = {"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 a[15];
int main() {
double x, y, z;
scanf("%lf%lf%lf", &x, &y, &z);
long double logx = log(x);
long double logy = log(y);
long double logz = log(z);
a[0] = logx * powl(y, z);
a[1] = logx * powl(z, y);
a[2] = logx * y * z;
a[3] = -1;
a[4] = logy * powl(x, z);
a[5] = logy * powl(z, x);
a[6] = logy * x * z;
a[7] = -1;
a[8] = logz * powl(x, y);
a[9] = logz * powl(y, x);
a[10] = logz * x * y;
a[11] = -1;
long double ans = a[0];
int pos = 0;
for (int i = 1; i < 12; i++) {
if (!fabs(ans - a[i]) < 1e-8 && a[i] > ans) {
ans = a[i];
pos = i;
}
}
printf("%s\n", out[pos]);
return 0;
}
|
#include <bits/stdc++.h>
std::string ans[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"};
const double EPS = 1e-10;
long double best;
int id;
bool better(long double val) {
if (fabs(val - best) < EPS)
return false;
else if (best < val) {
best = val;
return true;
}
return false;
}
void try2(long double x, long double y, long double z, int pos) {
long double val = z * y * log(x);
if (better(val)) id = pos;
}
void try1(long double x, long double y, long double z, int pos) {
long double val = powl(y, z) * log(x);
if (better(val)) id = pos;
}
int main(void) {
long double x, y, z;
std::cin >> x >> y >> z;
best = -1e12;
id = -1;
try1(x, y, z, 0);
try1(x, z, y, 1);
try2(x, y, z, 2);
try2(x, z, y, 3);
try1(y, x, z, 4);
try1(y, z, x, 5);
try2(y, x, z, 6);
try2(y, z, x, 7);
try1(z, x, y, 8);
try1(z, y, x, 9);
try2(z, x, y, 10);
try2(z, y, x, 11);
std::cout << ans[id] << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
struct LDBL {
long double l;
LDBL(long double ll) : l(ll){};
bool operator<(const LDBL& other) const { return l - other.l > EPS; }
bool operator==(const LDBL& other) const { return abs(other.l - l) < EPS; }
};
string res[] = {"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"};
int main() {
long double x, y, z;
cin >> x >> y >> z;
long double x1, y1, z1;
if (x > 5)
x1 = 5;
else
x1 = x;
if (y > 5)
y1 = 5;
else
y1 = y;
if (z > 5)
z1 = 5;
else
z1 = z;
if (x < 0.5) x1 = 0.5;
if (y < 0.5) y1 = 0.5;
if (z < 0.5) z1 = 0.5;
for (int i = (0); i < (int)(100); i++) {
while (x > y && !(x1 > y1)) x1 += 0.01;
while (x > z && !(x1 > z1)) x1 += 0.01;
while (y > x && !(y1 > x1)) y1 += 0.01;
while (y > z && !(y1 > z1)) y1 += 0.01;
while (z > x && !(z1 > x1)) z1 += 0.01;
while (z > y && !(z1 > y1)) z1 += 0.01;
}
pair<LDBL, int> a[] = {
{pow(x1, pow(y1, z1)), 0}, {pow(x1, pow(z1, y1)), 1},
{pow(pow(x1, y1), z1), 2}, {pow(pow(x1, z1), y1), 3},
{pow(y1, pow(x1, z1)), 4}, {pow(y1, pow(z1, x1)), 5},
{pow(pow(y1, x1), z1), 6}, {pow(pow(y1, z1), x1), 7},
{pow(z1, pow(x1, y1)), 8}, {pow(z1, pow(y1, x1)), 9},
{pow(pow(z1, x1), y1), 10}, {pow(pow(z1, y1), x1), 11}};
sort(a, a + 12);
cout << res[a[0].second] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
pair<int, long double> loglog(long double x) {
if (x >= 1)
return {1, log(log(x))};
else
return {0, log(abs(log(x)))};
}
int main() {
long double x, y, z;
cin >> x >> y >> z;
vector<tuple<int, long double, int, string>> vec;
vec.emplace_back(x >= 1, log(abs(log(x))) + log(y) * z, 8, "x^y^z");
vec.emplace_back(x >= 1, log(abs(log(x))) + log(z) * y, 7, "x^z^y");
vec.emplace_back(x >= 1, log(abs(log(x))) + log(y) + log(z), 6, "(x^y)^z");
vec.emplace_back(y >= 1, log(abs(log(y))) + log(x) * z, 5, "y^x^z");
vec.emplace_back(y >= 1, log(abs(log(y))) + log(z) * x, 4, "y^z^x");
vec.emplace_back(y >= 1, log(abs(log(y))) + log(x) + log(z), 3, "(y^x)^z");
vec.emplace_back(z >= 1, log(abs(log(z))) + log(x) * y, 2, "z^x^y");
vec.emplace_back(z >= 1, log(abs(log(z))) + log(y) * x, 1, "z^y^x");
vec.emplace_back(z >= 1, log(abs(log(z))) + log(x) + log(y), 0, "(z^x)^y");
for (auto &p : vec)
if (get<0>(p) == 0) get<1>(p) *= -1;
sort((vec).begin(), (vec).end());
cout << get<3>(vec.back()) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-12;
inline int sgn(long double u) {
if (u > eps)
return 1;
else if (u < -eps)
return -1;
else
return 0;
}
long double x, y, z;
long double a[12];
string ans[12];
pair<long double, int> u[12];
int main() {
while (cin >> x >> y >> z) {
ans[0] = "x^y^z";
ans[1] = "x^z^y";
ans[2] = "(x^y)^z";
ans[3] = "(x^z)^y";
ans[4] = "y^x^z";
ans[5] = "y^z^x";
ans[6] = "(y^x)^z";
ans[7] = "(y^z)^x";
ans[8] = "z^x^y";
ans[9] = "z^y^x";
ans[10] = "(z^x)^y";
ans[11] = "(z^y)^x";
a[0] = exp(z * log(y)) * log(x);
a[1] = exp(y * log(z)) * log(x);
a[2] = y * z * log(x);
a[3] = y * z * log(x);
a[4] = exp(z * log(x)) * log(y);
a[5] = exp(x * log(z)) * log(y);
a[6] = x * z * log(y);
a[7] = x * z * log(y);
a[8] = exp(y * log(x)) * log(z);
a[9] = exp(x * log(y)) * log(z);
a[10] = x * y * log(z);
a[11] = x * y * log(z);
for (int i = 0; i < 12; i++) {
u[i].first = -a[i];
u[i].second = i;
}
sort(u, u + 12);
cout << ans[u[0].second] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
inline int cmp(double x, double y = 0, double tol = 1e-7) {
return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
using namespace std;
inline long long gcd(long long a, long long b) {
return (b ? gcd(b, a % b) : a);
}
inline long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
const int MAXN = 300005;
long double a(long double x, long double y, long double z) {
long double aux = 1;
for (int i = 0; i < (int)z; i++) {
aux *= y;
}
aux *= (pow(y, z - (int)z));
return aux * ((long double)log(x));
}
long double b(long double x, long double y, long double z) {
return y * z * log(x);
}
string ans[12];
long double v[12];
int main() {
long double maior = -10000007, r;
double x, y, z;
cin >> x >> y >> z;
if (true) {
ans[0] = "x^y^z";
ans[1] = "x^z^y";
ans[2] = "y^x^z";
ans[3] = "y^z^x";
ans[4] = "z^x^y";
ans[5] = "z^y^x";
ans[6] = "(x^y)^z";
ans[7] = "(x^z)^y";
ans[8] = "(y^x)^z";
ans[9] = "(y^z)^x";
ans[10] = "(z^x)^y";
ans[11] = "(z^y)^x";
maior = max(maior, v[0] = a(x, y, z));
maior = max(maior, v[1] = a(x, z, y));
maior = max(maior, v[2] = a(y, x, z));
maior = max(maior, v[3] = a(y, z, x));
maior = max(maior, v[4] = a(z, x, y));
maior = max(maior, v[5] = a(z, y, x));
maior = max(maior, v[6] = b(x, y, z));
maior = max(maior, v[7] = b(x, z, y));
maior = max(maior, v[8] = b(y, x, z));
maior = max(maior, v[9] = b(y, z, x));
maior = max(maior, v[10] = b(z, x, y));
maior = max(maior, v[11] = b(z, y, x));
for (int i = 0; i < 12; i++) {
}
for (int i = 0; i < 12; i++) {
if (v[i] == maior) {
cout << ans[i] << endl;
break;
}
}
return 0;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long double eps = 0.00000001;
struct Number {
long double x, y, z;
Number() {}
Number(long double x, long double y, long double z) {
this->x = x;
this->y = y;
this->z = z;
}
};
bool cmp(Number A, Number B) {
if (A.x == 1) {
if (B.x < 1) return true;
return false;
}
if (B.x == 1) {
if (A.x < 1) return false;
return true;
}
if (A.x < 3 && A.y < 3 && A.z < 3) {
return (pow(A.x, pow(A.y, A.z)) - eps > pow(B.x, pow(B.y, B.z)));
}
A.x = log(A.x);
B.x = log(B.x);
if (A.x > eps && B.x < -eps) return true;
if (A.x < -eps && B.x > eps) return false;
bool inv = false;
if (A.x < -eps && B.x < -eps) A.x *= -1, B.x *= -1, inv = true;
if (A.x > -eps && A.x < eps) A.x = eps / 100;
if (B.x > -eps && B.x < eps) B.x = eps / 100;
long double a = log(A.x) + log(A.y) * A.z;
long double b = log(B.x) + log(B.y) * B.z;
if (abs(a - b) < eps) return false;
return ((a > b) ^ inv);
}
Number a[12];
string ans[12];
void init(long double x, long double y, long double z) {
a[0] = Number(x, y, z);
ans[0] = "x^y^z";
a[1] = Number(x, z, y);
ans[1] = "x^z^y";
a[2] = Number(x, y * z, 1);
ans[2] = "(x^y)^z";
a[4] = Number(y, x, z);
ans[4] = "y^x^z";
a[5] = Number(y, z, x);
ans[5] = "y^z^x";
a[6] = Number(y, x * z, 1);
ans[6] = "(y^x)^z";
a[8] = Number(z, x, y);
ans[8] = "z^x^y";
a[9] = Number(z, y, x);
ans[9] = "z^y^x";
a[10] = Number(z, x * y, 1);
ans[10] = "(z^x)^y";
}
int main() {
long double x, y, z;
cin >> x >> y >> z;
init(x, y, z);
int bestInd = 0;
for (int i = 1; i < 12; i++) {
if (i == 3 || i == 7 || i == 11) continue;
if (a[i].x == 1 && a[bestInd].x > 1) continue;
if (cmp(a[i], a[bestInd]) == true) bestInd = i;
}
cout << ans[bestInd] << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
char print[13][10] = {"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 a[20];
int main() {
long double x, y, z;
while (cin >> x >> y >> z) {
long double x1 = log(x);
long double y1 = log(y);
long double z1 = log(z);
a[0] = x1 * pow(y, z);
a[1] = x1 * pow(z, y);
a[2] = a[3] = x1 * y * z;
a[4] = y1 * pow(x, z);
a[5] = y1 * pow(z, x);
a[6] = a[7] = y1 * x * z;
a[8] = z1 * pow(x, y);
a[9] = z1 * pow(y, x);
a[10] = a[11] = z1 * x * y;
long double Max = -1;
int flag;
for (int i = 0; i < 12; i++) {
if (a[i] > Max) {
Max = a[i];
flag = i;
}
}
printf("%s\n", print[flag]);
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long double ESP = 1E-8;
long double cal(long double x, long double y, long double z) {
return log(x) * pow(y, z);
}
long double ca(long double x, long double y, long double z) {
return y * z * log(x);
}
int main() {
const char* result[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 a[20];
long double x, y, z;
cin >> x >> y >> z;
a[0] = cal(x, y, z);
a[1] = cal(x, z, y);
a[2] = ca(x, y, z);
a[3] = ca(x, z, y);
a[4] = cal(y, x, z);
a[5] = cal(y, z, x);
a[6] = ca(y, x, z);
a[7] = ca(y, z, x);
a[8] = cal(z, x, y);
a[9] = cal(z, y, x);
a[10] = ca(z, x, y);
a[11] = ca(z, y, x);
long double maxn = a[0];
int res = 0;
for (int i = 1; i < 12; ++i) {
if (maxn < a[i] - ESP) {
maxn = a[i];
res = i;
}
}
printf("%s", result[res]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const long long INF = (long long)1e18;
int sign(long double x) { return x < -eps ? -1 : x > eps; }
bool bigger(const complex<long double> &a, const complex<long double> &b) {
if (sign(imag(a)) == 0 && sign(imag(b)) == 0)
return sign(real(a) - real(b)) > 0;
if (sign(imag(a)) == 1 && sign(imag(b)) == 1)
return sign(real(a) - real(b)) < 0;
return sign(imag(a) - imag(b)) < 0;
}
complex<long double> x, y, z, maxn;
string s = "x^y^z";
int main() {
cin >> x >> y >> z;
maxn = z * log(y) + log(log(x));
if (bigger(y * log(z) + log(log(x)), maxn)) {
maxn = y * log(z) + log(log(x));
s = "x^z^y";
}
if (bigger(log(y * z) + log(log(x)), maxn)) {
maxn = log(y * z) + log(log(x));
s = "(x^y)^z";
}
if (bigger(z * log(x) + log(log(y)), maxn)) {
maxn = z * log(x) + log(log(y));
s = "y^x^z";
}
if (bigger(x * log(z) + log(log(y)), maxn)) {
maxn = x * log(z) + log(log(y));
s = "y^z^x";
}
if (bigger(log(x * z) + log(log(y)), maxn)) {
maxn = log(x * z) + log(log(y));
s = "(y^x)^z";
}
if (bigger(y * log(x) + log(log(z)), maxn)) {
maxn = y * log(x) + log(log(z));
s = "z^x^y";
}
if (bigger(x * log(y) + log(log(z)), maxn)) {
maxn = x * log(y) + log(log(z));
s = "z^y^x";
}
if (bigger(log(x * y) + log(log(z)), maxn)) {
maxn = log(x * y) + log(log(z));
s = "(z^x)^y";
}
cout << s << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long mInv[41];
long long fact[41];
long long factInv[41];
map<long, long> mymap;
set<string> dictionary;
set<string>::iterator it;
pair<set<string>::iterator, bool> ret;
long long getmoduloInv(long long n) {
if (n == 1) return 1;
if (mInv[n] > 0) return mInv[n];
long long m = (-1 * 1000000007) / n;
m += 1000000007;
m *= getmoduloInv(1000000007 % n);
mInv[n] = (m % 1000000007);
return mInv[n];
}
double getDist(double x1, double y1, double x2, double y2, double x3,
double y3) {
double dist1 = ((x1 - x3) * (x1 - x3)) + ((y1 - y3) * (y1 - y3));
double dist2 = ((x2 - x3) * (x2 - x3)) + ((y2 - y3) * (y2 - y3));
double dist3 = ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2));
if (dist3 < 0.00000002) return (dist1 + dist2) / 2;
if (dist1 < dist2)
return getDist(x1, y1, (x1 + x2) / 2, (y1 + y2) / 2, x3, y3);
return getDist(x2, y2, (x1 + x2) / 2, (y1 + y2) / 2, x3, y3);
}
long long C[100005], N, L, M, D;
long long cumCost[100005];
long findPos(long val) {
long long pos = 0, total = 0;
while (cumCost[pos] <= val) {
pos++;
}
return pos;
}
long long x[2020], y[2020];
typedef pair<long long, long long> flower;
vector<flower> flowers;
void printVal(long long v) {
if (v < 1) return;
long long temp = 1, val = 0;
while (temp <= v) {
val++;
temp = temp << 1;
}
cout << val << " ";
if (temp > v) printVal(v - (temp / 2));
}
double vals[13];
void fillVals(double b, double p1, double p2, long startPoint) {
if (b < 1.0)
vals[startPoint] = vals[startPoint + 1] = vals[startPoint + 2] = 0.0;
else {
vals[startPoint] = log(log(b)) + p2 * log(p1);
vals[startPoint + 1] = log(log(b)) + p1 * log(p2);
vals[startPoint + 2] = log(log(b)) + log(p1) + log(p2);
}
}
int main(void) {
long long test_cases = 1;
cout << setprecision(15) << fixed;
long long n;
bool found = false;
double x, y, z;
cin >> x >> y >> z;
if (x < 4 && y < 4 && z < 4) {
vals[0] = pow(x, (pow(y, z)));
vals[1] = pow(x, (pow(z, y)));
vals[2] = pow(x, (y * z));
vals[3] = pow(y, (pow(x, z)));
vals[4] = pow(y, (pow(z, x)));
vals[5] = pow(y, (x * z));
vals[6] = pow(z, (pow(x, y)));
vals[7] = pow(z, (pow(y, x)));
vals[8] = pow(z, (x * y));
} else {
fillVals(x, y, z, 0);
fillVals(y, x, z, 3);
fillVals(z, x, y, 6);
}
long minPos = 0;
for (long i = 1; i < 9; i++) {
if (vals[i] > vals[minPos] + 0.00000002) minPos = i;
}
if (minPos == 0)
cout << "x^y^z" << endl;
else if (minPos == 1)
cout << "x^z^y" << endl;
else if (minPos == 2)
cout << "(x^y)^z" << endl;
if (minPos == 3)
cout << "y^x^z" << endl;
else if (minPos == 4)
cout << "y^z^x" << endl;
else if (minPos == 5)
cout << "(y^x)^z" << endl;
if (minPos == 6)
cout << "z^x^y" << endl;
else if (minPos == 7)
cout << "z^y^x" << endl;
else if (minPos == 8)
cout << "(z^x)^y" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double EPS = 0.000000001;
map<int, long double> fazc;
long double calc1(vector<int> &a) {
long double retorno = pow(fazc[a[1]], fazc[a[2]]);
retorno *= log(fazc[a[0]]);
return retorno;
}
long double calc2(vector<int> &a) {
long double retorno = fazc[a[2]] * fazc[a[1]];
retorno *= log(fazc[a[0]]);
return retorno;
}
int main() {
long double x, y, z;
cin >> x >> y >> z;
vector<int> a(3, 0);
vector<int> trad(3, 0);
a[1] = 1;
a[2] = 2;
trad[1] = 1;
trad[2] = 2;
map<int, char> m;
m[0] = 'x';
m[1] = 'y';
m[2] = 'z';
fazc[0] = x;
fazc[1] = y;
fazc[2] = z;
bool primeiro = true;
long double max1 = calc1(a);
for (int i = 0; i < 6; i++) {
long double auxi = calc1(a);
if (auxi > max1 + EPS) {
max1 = auxi;
primeiro = true;
for (int j = 0; j < 3; j++) trad[j] = a[j];
}
next_permutation(a.begin(), a.begin() + 3);
}
sort(a.begin(), a.end());
long double max2 = calc2(a);
vector<int> trad2(3, 0);
trad2[1] = 1;
trad2[2] = 2;
for (int i = 0; i < 6; i++) {
long double auxi = calc2(a);
auxi = calc2(a);
if (auxi > max2 + EPS) {
max2 = auxi;
primeiro = false;
for (int j = 0; j < 3; j++) trad2[j] = a[j];
}
next_permutation(a.begin(), a.begin() + 3);
}
if (abs(max1 - max2) < EPS) {
cout << m[trad[0]] << "^" << m[trad[1]] << "^" << m[trad[2]] << endl;
return 0;
}
if (max1 > max2) {
cout << m[trad[0]] << "^" << m[trad[1]] << "^" << m[trad[2]] << endl;
return 0;
}
cout << "(" << m[trad2[0]] << "^" << m[trad2[1]] << ")^" << m[trad2[2]]
<< endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double eps = FLT_MIN, inf = 1e60;
long double x, y, z;
long double f(int idx) {
if (idx == 1) return (x <= 1.) ? -inf : z * log(y) + log(log(x));
if (idx == 2) return (x <= 1.) ? -inf : y * log(z) + log(log(x));
if (idx == 3 || idx == 4)
return (x <= 1.) ? -inf : log(z) + log(y) + log(log(x));
if (idx == 5) return (y <= 1.) ? -inf : z * log(x) + log(log(y));
if (idx == 6) return (y <= 1.) ? -inf : x * log(z) + log(log(y));
if (idx == 7 || idx == 8)
return (y <= 1.) ? -inf : log(z) + log(x) + log(log(y));
if (idx == 9) return (z <= 1.) ? -inf : y * log(x) + log(log(z));
if (idx == 10) return (z <= 1.) ? -inf : x * log(y) + log(log(z));
if (idx == 11 || idx == 12)
return (z <= 1.) ? -inf : log(x) + log(y) + log(log(z));
}
long double g(int idx) {
if (idx == 1) return pow(x, pow(y, z));
if (idx == 2) return pow(x, pow(z, y));
if (idx == 3 || idx == 4) return pow(x, y * z);
if (idx == 5) return pow(y, pow(x, z));
if (idx == 6) return pow(y, pow(z, x));
if (idx == 7 || idx == 8) return pow(y, x * z);
if (idx == 9) return pow(z, pow(x, y));
if (idx == 10) return pow(z, pow(y, x));
if (idx == 11 || idx == 12) return pow(z, y * x);
}
long double t(int idx) {
return (x <= 1 && y <= 1 && z <= 1) ? g(idx) : f(idx);
}
int main() {
map<int, string> ans;
ans[1] = "x^y^z";
ans[2] = "x^z^y";
ans[3] = "(x^y)^z";
ans[4] = "(x^z)^y";
ans[5] = "y^x^z";
ans[6] = "y^z^x";
ans[7] = "(y^x)^z";
ans[8] = "(y^z)^x";
ans[9] = "z^x^y";
ans[10] = "z^y^x";
ans[11] = "(z^x)^y";
ans[12] = "(z^y)^x";
cin >> x >> y >> z;
long double maxi;
int idx = -1;
for (int i = 1; i <= 12; i++) {
fprintf(stderr, "t(%d) = %.10Lf\n", i, t(i));
if (idx == -1 || (t(i) - maxi > eps)) maxi = t(i), idx = i;
}
cout << ans[idx] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-12;
inline bool eq(const long double &x, const long double &y) {
return abs(x - y) < eps || abs(x - y) < eps * abs(x);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
long double x, y, z;
cin >> x >> y >> z;
long double logx = log(x);
long double logy = log(y);
long double logz = log(z);
long double A[] = {logx * pow(y, z), logx * pow(z, y), logx * y * z,
logx * y * z, logy * pow(x, z), logy * pow(z, x),
logy * x * z, logy * x * z, logz * pow(x, y),
logz * pow(y, x), logz * x * y, logz * x * y};
int ans = 0;
long double mx = -1;
for (int i = 0; i < 12; i++) {
if (!eq(A[i], mx) && A[i] > mx) {
mx = A[i];
ans = i;
}
}
string B[] = {"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"};
cout << B[ans] << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
inline bool Min(T &a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
inline bool Max(T &a, T b) {
return a < b ? (a = b, true) : false;
}
inline int ni() {
int a;
scanf("%d", &a);
return a;
}
inline ll nl() {
ll a;
scanf("%lld", &a);
return a;
}
inline double nd() {
double a;
scanf("%lf", &a);
return a;
}
inline void pi(int a) { printf("%d ", a); }
inline void pl(ll a) { printf("%lld ", a); }
inline void pd(double a) { printf("%.12lf ", a); }
const int N = 1e5 + 10;
using ld = long double;
void solve() {
ld x, y, z;
cin >> x >> y >> z;
ld ans[10];
ans[1] = log(x) * pow(y, z);
ans[2] = log(x) * pow(z, y);
ans[3] = log(x) * y * z;
ans[4] = log(y) * pow(x, z);
ans[5] = log(y) * pow(z, x);
ans[6] = log(y) * x * z;
ans[7] = log(z) * pow(x, y);
ans[8] = log(z) * pow(y, x);
ans[9] = log(z) * x * y;
ans[0] = ans[1];
int t = 1;
for (int i = 1; i <= 9; i++)
if (Max(ans[0], ans[i])) t = i;
if (t == 1) puts("x^y^z");
if (t == 2) puts("x^z^y");
if (t == 3) puts("(x^y)^z");
if (t == 4) puts("y^x^z");
if (t == 5) puts("y^z^x");
if (t == 6) puts("(y^x)^z");
if (t == 7) puts("z^x^y");
if (t == 8) puts("z^y^x");
if (t == 9) puts("(z^x)^y");
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-15;
double x, y, z, arr[12];
int main() {
ios::sync_with_stdio(0);
cin >> x >> y >> z;
int cnt = (x < 1) + (y < 1) + (z < 1);
if (cnt != 3) {
if (x > 1) {
arr[1] = log(y) * z + log(log(x));
arr[2] = log(z) * y + log(log(x));
arr[3] = log(y) + log(z) + log(log(x));
} else if (x < 1)
arr[1] = arr[2] = arr[3] = -1e18;
else
arr[1] = arr[2] = arr[3] = -1e17;
if (y > 1) {
arr[4] = log(x) * z + log(log(y));
arr[5] = log(z) * x + log(log(y));
arr[6] = log(x) + log(z) + log(log(y));
} else if (y < 1)
arr[4] = arr[5] = arr[6] = -1e18;
else
arr[4] = arr[5] = arr[6] = -1e17;
if (z > 1) {
arr[7] = log(x) * y + log(log(z));
arr[8] = log(y) * x + log(log(z));
arr[9] = log(x) + log(y) + log(log(z));
} else if (z < 1)
arr[7] = arr[8] = arr[9] = -1e18;
else
arr[7] = arr[8] = arr[9] = -1e17;
} else {
arr[1] = -(log(y) * z + log(log(1 / x)));
arr[2] = -(log(z) * y + log(log(1 / x)));
arr[3] = -(log(y) + log(z) + log(log(1 / x)));
arr[4] = -(log(x) * z + log(log(1 / y)));
arr[5] = -(log(z) * x + log(log(1 / y)));
arr[6] = -(log(x) + log(z) + log(log(1 / y)));
arr[7] = -(log(x) * y + log(log(1 / z)));
arr[8] = -(log(y) * x + log(log(1 / z)));
arr[9] = -(log(x) + log(y) + log(log(1 / z)));
}
int mx = 1;
for (int i = 2; i < 10; ++i)
if (arr[i] > arr[mx]) mx = i;
if (mx == 1) cout << "x^y^z";
if (mx == 2) cout << "x^z^y";
if (mx == 3) cout << "(x^y)^z";
if (mx == 4) cout << "y^x^z";
if (mx == 5) cout << "y^z^x";
if (mx == 6) cout << "(y^x)^z";
if (mx == 7) cout << "z^x^y";
if (mx == 8) cout << "z^y^x";
if (mx == 9) cout << "(z^x)^y";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return (y ? gcd(y, x % y) : x); }
long long lcm(long long x, long long y) { return x * (y / gcd(x, y)); }
long double one(long double x, long double y, long double z) {
return pow(y, z) * log(x);
}
long double two(long double x, long double y, long double z) {
return z * y * log(x);
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
vector<long double> x(3);
for (int i = 0; i < 3; i++) {
int p, d;
char aux;
cin >> p >> aux >> d;
x[i] = (double)(p * 10.0 + d) / 10.0;
}
int cnt = 0;
int ans = -1;
long double mx = -1e9;
bool f = false;
vector<string> a = {"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"};
vector<long double> as(12);
for (int i = 0; i < 3; i++) {
if (i) cnt += 2;
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (i != j && i != k && k != j) {
long double o = one(x[i], x[j], x[k]);
if (o > mx) mx = o;
as[cnt] = o;
long double t = two(x[i], x[j], x[k]);
if (t > mx) mx = t;
as[cnt + 2] = t;
cnt++;
}
}
}
}
for (int i = 0; i < 12; i++) {
if (as[i] == mx) {
cout << a[i] << endl;
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10 + 10;
const double EPS = 1e-8;
long double a[MAXN];
string s[MAXN] = {"", "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"};
int main() {
long double x, y, z;
while (cin >> x >> y >> z) {
a[1] = pow(y, z) * log(x);
a[2] = pow(z, y) * log(x);
a[3] = z * y * log(x);
a[4] = y * z * log(x);
a[5] = pow(x, z) * log(y);
a[6] = pow(z, x) * log(y);
a[7] = z * x * log(y);
a[8] = x * z * log(y);
a[9] = pow(x, y) * log(z);
a[10] = pow(y, x) * log(z);
a[11] = y * x * log(z);
a[12] = x * y * log(z);
int MaxID = 1;
for (int i = 1; i <= 12; ++i) {
if (a[i] - a[MaxID] > EPS) MaxID = i;
}
cout << s[MaxID] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double a[3];
char ch[3] = {'x', 'y', 'z'};
const long double eps = 1e-15;
struct Node {
int form;
int ord[3];
long double x, y, z;
Node(int o0, int o1, int o2, int _form) {
ord[0] = o0;
ord[1] = o1;
ord[2] = o2;
x = a[o0];
y = a[o1];
z = a[o2];
form = _form;
}
bool operator<(Node& o) {
if (fabs(x - 1) < eps && fabs(o.x - 1) < eps) {
return false;
}
long double logx1 = log(x), logx2 = log(o.x);
if (fabs(logx1) < eps) {
return logx2 > 0;
}
if (fabs(logx2) < eps) {
return logx1 < 0;
}
if (logx1 > 0 && logx2 < 0) {
return false;
}
if (logx1 < 0 && logx2 > 0) {
return true;
}
long double k1 = Gao(y, z, form) + log(abs(logx1)),
k2 = Gao(o.y, o.z, o.form) + log(abs(logx2));
return logx1 < 0 ? k1 > k2 : k1 < k2;
}
long double Gao(long double y, long double z, int form) {
if (form == 0) {
return z * log(y);
} else {
return log(y) + log(z);
}
}
void Output() {
if (form == 0) {
cout << ch[ord[0]] << "^" << ch[ord[1]] << "^" << ch[ord[2]] << endl;
} else {
cout << "(" << ch[ord[0]] << "^" << ch[ord[1]] << ")^" << ch[ord[2]]
<< endl;
}
}
};
void Update(Node& x, Node y) {
if (x < y) {
x = y;
}
}
int main() {
long double x, y, z;
while (cin >> x >> y >> z) {
a[0] = x;
a[1] = y;
a[2] = z;
Node maxv = Node(0, 1, 2, 0);
Update(maxv, Node(0, 2, 1, 0));
Update(maxv, Node(0, 1, 2, 1));
Update(maxv, Node(1, 0, 2, 0));
Update(maxv, Node(1, 2, 0, 0));
Update(maxv, Node(1, 0, 2, 1));
Update(maxv, Node(2, 0, 1, 0));
Update(maxv, Node(2, 1, 0, 0));
Update(maxv, Node(2, 0, 1, 1));
maxv.Output();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<string> ve = {"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 x, y, z;
void get(char c, long double &a) {
if (c == 'x') a = x;
if (c == 'y') a = y;
if (c == 'z') a = z;
}
long double calc(string s) {
long double a, b, c;
get(s.back(), c);
s.pop_back();
s.pop_back();
if (s.back() == ')') {
s.pop_back();
get(s.back(), b);
s.pop_back();
s.pop_back();
get(s.back(), a);
return b * c * log(a);
} else {
get(s.back(), b);
s.pop_back();
s.pop_back();
get(s.back(), a);
return pow(b, c) * log(a);
}
}
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> x >> y >> z;
long double ans = -1;
int id = -1;
for (int i = 0; i < 12; i++) {
long double t = calc(ve[i]);
if (t > ans) {
ans = t;
id = i;
}
}
cout << ve[id] << endl;
return 0;
}
|
#include <bits/stdc++.h>
const double pi = (double)(2.0 * acos(0.0));
const int inf = 1 << 30;
const double eps = 1E-9;
const double e = exp(1.0);
const int sz = 100000 + 5;
const int mod = 1000000000 + 7;
using namespace std;
int main() {
double x, y, z, res, v;
string st = "";
scanf("%lf %lf %lf", &x, &y, &z);
if (x < 1.0 + eps && y < 1.0 + eps && z < 1.0 + eps) {
res = 1e18;
v = z * log(y) + log(log(1.0 / x));
if (res > v + eps) res = v, st = "x^y^z";
v = y * log(z) + log(log(1.0 / x));
if (res > v + eps) res = v, st = "x^z^y";
v = log(y) + log(z) + log(log(1.0 / x));
if (res > v + eps) res = v, st = "(x^y)^z";
v = z * log(x) + log(log(1.0 / y));
if (res > v + eps) res = v, st = "y^x^z";
v = x * log(z) + log(log(1.0 / y));
if (res > v + eps) res = v, st = "y^z^x";
v = log(x) + log(z) + log(log(1.0 / y));
if (res > v + eps) res = v, st = "(y^x)^z";
v = y * log(x) + log(log(1.0 / z));
if (res > v + eps) res = v, st = "z^x^y";
v = x * log(y) + log(log(1.0 / z));
if (res > v + eps) res = v, st = "z^y^x";
v = log(x) + log(y) + log(log(1.0 / z));
if (res > v + eps) res = v, st = "(z^x)^y";
cout << st << endl;
} else {
res = -1e18;
if (x > 1.0 + eps) {
v = z * log(y) + log(log(x));
if (res + eps < v) res = v, st = "x^y^z";
v = y * log(z) + log(log(x));
if (res + eps < v) res = v, st = "x^z^y";
v = log(y) + log(z) + log(log(x));
if (res + eps < v) res = v, st = "(x^y)^z";
}
if (y > 1.0 + eps) {
v = z * log(x) + log(log(y));
if (res + eps < v) res = v, st = "y^x^z";
v = x * log(z) + log(log(y));
if (res + eps < v) res = v, st = "y^z^x";
v = log(x) + log(z) + log(log(y));
if (res + eps < v) res = v, st = "(y^x)^z";
}
if (z > 1.0 + eps) {
v = y * log(x) + log(log(z));
if (res + eps < v) res = v, st = "z^x^y";
v = x * log(y) + log(log(z));
if (res + eps < v) res = v, st = "z^y^x";
v = log(x) + log(y) + log(log(z));
if (res + eps < v) res = v, st = "(z^x)^y";
}
cout << st << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int dx[5] = {0, 1, -1, 0, 0};
const int dy[5] = {0, 0, 0, -1, 1};
const double pi = acos(-1.0);
long double x, y, z;
long double ans[15];
void input_LL(long long &r) {
r = 0;
char t = getchar();
while (!isdigit(t)) t = getchar();
long long sign = 1;
if (t == '-') sign = -1;
while (!isdigit(t)) t = getchar();
while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
r = r * sign;
}
void input_int(int &r) {
r = 0;
char t = getchar();
while (!isdigit(t)) t = getchar();
int sign = 1;
if (t == '-') sign = -1;
while (!isdigit(t)) t = getchar();
while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
r = r * sign;
}
int main() {
cin >> x >> y >> z;
ans[1] = pow(y, z) * log(x);
ans[2] = pow(z, y) * log(x);
ans[3] = z * y * log(x);
ans[4] = ans[3];
ans[5] = pow(x, z) * log(y);
ans[6] = pow(z, x) * log(y);
ans[7] = x * z * log(y);
ans[8] = ans[7];
ans[9] = pow(x, y) * log(z);
ans[10] = pow(y, x) * log(z);
ans[11] = x * y * log(z);
ans[12] = ans[11];
int j = 1;
for (int i = 2; i <= 12; i++)
if (ans[j] < ans[i]) j = i;
switch (j) {
case 1:
puts("x^y^z");
break;
case 2:
puts("x^z^y");
break;
case 3:
puts("(x^y)^z");
break;
case 4:
puts("(x^z)^y");
break;
case 5:
puts("y^x^z");
break;
case 6:
puts("y^z^x");
break;
case 7:
puts("(y^x)^z");
break;
case 8:
puts("(y^z)^x");
break;
case 9:
puts("z^x^y");
break;
case 10:
puts("z^y^x");
break;
case 11:
puts("(z^x)^y");
break;
case 12:
puts("(z^y)^x");
break;
}
return 0;
}
|
#include <bits/stdc++.h>
double res[10];
int ans = 0;
void calc(double x, double y, double z, double &res1, double &res2,
double &res3) {
if (x <= 1.0) {
res1 = res2 = res3 = -2000.0;
return;
}
res1 = z * log(y) + log(log(x));
res2 = y * log(z) + log(log(x));
res3 = log(y) + log(z) + log(log(x));
}
void printf_Result() {
switch (ans) {
case 0:
puts("x^y^z");
break;
case 1:
puts("x^z^y");
break;
case 2:
puts("(x^y)^z");
break;
case 3:
puts("y^x^z");
break;
case 4:
puts("y^z^x");
break;
case 5:
puts("(y^x)^z");
break;
case 6:
puts("z^x^y");
break;
case 7:
puts("z^y^x");
break;
case 8:
puts("(z^x)^y");
break;
}
}
int main() {
double x, y, z;
scanf("%lf %lf %lf", &x, &y, &z);
if (x <= 1 && y <= 1 && z <= 1) {
res[0] = pow(y, z) * log(x);
res[1] = pow(z, y) * log(x);
res[2] = y * z * log(x);
res[3] = pow(z, x) * log(y);
res[4] = pow(x, z) * log(y);
res[5] = z * x * log(y);
res[6] = pow(y, x) * log(z);
res[7] = pow(x, y) * log(z);
res[8] = x * y * log(z);
for (int i = 1; i <= 8; ++i)
if (res[i] > res[ans]) ans = i;
printf_Result();
return 0;
}
calc(x, y, z, res[0], res[1], res[2]);
calc(y, x, z, res[3], res[4], res[5]);
calc(z, x, y, res[6], res[7], res[8]);
for (int i = 1; i <= 8; ++i)
if (res[i] > res[ans]) ans = i;
printf_Result();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int mod = (int)1e+9 + 7;
const double pi = acos(-1.);
bool compare(complex<long double> a, complex<long double> b) {
if (imag(a) == 0 && imag(b) == 0) {
return real(a) > real(b);
} else if (imag(a) == 0 && imag(b) != 0) {
return true;
} else if (imag(a) != 0 && imag(b) == 0) {
return false;
} else if (imag(a) != 0 && imag(b) != 0) {
return real(a) < real(b);
}
return (true);
}
int main() {
{
srand(time(0));
const string file = "";
if (!file.empty()) {
freopen((file + ".in").c_str(), "r", stdin);
freopen((file + ".out").c_str(), "w", stdout);
}
}
long double ax, ay, az;
cin >> ax >> ay >> az;
complex<long double> x(ax, 0.0L);
complex<long double> y(ay, 0.0L);
complex<long double> z(az, 0.0L);
complex<long double> ansc(3, 3);
string ans = "...";
if (compare(z * log(y) + log(log(x)), ansc)) {
ansc = z * log(y) + log(log(x));
ans = "x^y^z";
}
if (compare(y * log(z) + log(log(x)), ansc)) {
ansc = y * log(z) + log(log(x));
ans = "x^z^y";
}
if (compare(log(y * z) + log(log(x)), ansc)) {
ansc = log(y * z) + log(log(x));
ans = "(x^y)^z";
}
if (compare(z * log(x) + log(log(y)), ansc)) {
ansc = z * log(x) + log(log(y));
ans = "y^x^z";
}
if (compare(x * log(z) + log(log(y)), ansc)) {
ansc = x * log(z) + log(log(y));
ans = "y^z^x";
}
if (compare(log(x * z) + log(log(y)), ansc)) {
ansc = log(x * z) + log(log(y));
ans = "(y^x)^z";
}
if (compare(y * log(x) + log(log(z)), ansc)) {
ansc = y * log(x) + log(log(z));
ans = "z^x^y";
}
if (compare(x * log(y) + log(log(z)), ansc)) {
ansc = x * log(y) + log(log(z));
ans = "z^y^x";
}
if (compare(log(x * y) + log(log(z)), ansc)) {
ansc = log(x * y) + log(log(z));
ans = "(z^x)^y";
}
cout << ans;
return (0);
}
|
#include <bits/stdc++.h>
using namespace std;
char str[12][10] = {"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"};
bool cmp(complex<long double> x, complex<long double> y) {
if (imag(x) == 0 && imag(y) == 0) {
return real(x) > real(y);
} else if (imag(x) == 0 && imag(y) != 0) {
return true;
} else if (imag(x) != 0 && imag(y) == 0) {
return false;
} else {
return real(x) < real(y);
}
}
complex<long double> arr[12];
int main() {
long double a, b, c;
cin >> a >> b >> c;
complex<long double> x(a, 0.0L);
complex<long double> y(b, 0.0L);
complex<long double> z(c, 0.0L);
arr[0] = z * log(y) + log(log(x));
arr[1] = y * log(z) + log(log(x));
arr[2] = log(y * z) + log(log(x));
arr[3] = arr[2];
arr[4] = z * log(x) + log(log(y));
arr[5] = x * log(z) + log(log(y));
arr[6] = log(x * z) + log(log(y));
arr[7] = arr[6];
arr[8] = y * log(x) + log(log(z));
arr[9] = x * log(y) + log(log(z));
arr[10] = log(x * y) + log(log(z));
arr[11] = arr[10];
int idx = 0;
for (int i = 1; i < 12; i++) {
if (cmp(arr[i], arr[idx])) {
idx = i;
}
}
printf("%s\n", str[idx]);
return 0;
}
|
#include <bits/stdc++.h>
double x, y, z;
int ans;
double num[15];
int main() {
int i;
for (i = 1; i <= 12; i++) num[i] = -1e100;
scanf("%lf%lf%lf", &x, &y, &z);
if (x <= 1 && y <= 1 && z <= 1) {
num[1] = pow(x, pow(y, z));
num[2] = pow(x, pow(z, y));
num[3] = pow(pow(x, y), z);
num[5] = pow(y, pow(x, z));
num[6] = pow(y, pow(z, z));
num[7] = pow(pow(y, x), z);
num[9] = pow(z, pow(x, y));
num[10] = pow(z, pow(y, x));
num[11] = pow(pow(z, x), y);
} else {
if (x > 1) {
num[1] = z * log(y) + log(log(x));
num[2] = y * log(z) + log(log(x));
num[3] = log(y) + log(z) + log(log(x));
}
if (y > 1) {
num[5] = z * log(x) + log(log(y));
num[6] = x * log(z) + log(log(y));
num[7] = log(x) + log(z) + log(log(y));
}
if (z > 1) {
num[9] = y * log(x) + log(log(z));
num[10] = x * log(y) + log(log(z));
num[11] = log(x) + log(y) + log(log(z));
}
}
for (ans = 1, i = 2; i <= 12; i++)
if (num[i] > num[ans] + 1e-6) ans = i;
if (ans == 1)
printf("x^y^z");
else if (ans == 2)
printf("x^z^y");
else if (ans == 3)
printf("(x^y)^z");
else if (ans == 5)
printf("y^x^z");
else if (ans == 6)
printf("y^z^x");
else if (ans == 7)
printf("(y^x)^z");
else if (ans == 9)
printf("z^x^y");
else if (ans == 10)
printf("z^y^x");
else
printf("(z^x)^y");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
int main() {
long double x, y, z;
cin >> x >> y >> z;
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 ans = 0.0, res[12];
int index;
res[0] = pow(y, z) * log(x);
res[1] = pow(z, y) * log(x);
res[2] = y * z * log(x);
res[3] = z * y * log(x);
res[4] = pow(x, z) * log(y);
res[5] = pow(z, x) * log(y);
res[6] = x * z * log(y);
res[7] = z * x * log(y);
res[8] = pow(x, y) * log(z);
res[9] = pow(y, x) * log(z);
res[10] = x * y * log(z);
res[11] = y * x * log(z);
ans = res[0];
index = 0;
for (int i = 0; i < 12; i++)
if (res[i] > ans) ans = res[i], index = i;
cout << s[index] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
namespace mainns {
class Solver621D {
public:
void run();
};
void Solver621D::run() {
vector<string> formulas = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
vector<function<complex<double>(complex<double>, complex<double>,
complex<double>)>>
functors = {
[](complex<double> x, complex<double> y, complex<double> z) {
return log(log(x)) + z * log(y);
},
[](complex<double> x, complex<double> y, complex<double> z) {
return log(log(x)) + y * log(z);
},
[](complex<double> x, complex<double> y, complex<double> z) {
return log(log(x)) + log(y) + log(z);
},
[](complex<double> x, complex<double> y, complex<double> z) {
return log(log(y)) + z * log(x);
},
[](complex<double> x, complex<double> y, complex<double> z) {
return log(log(y)) + x * log(z);
},
[](complex<double> x, complex<double> y, complex<double> z) {
return log(log(y)) + log(x) + log(z);
},
[](complex<double> x, complex<double> y, complex<double> z) {
return log(log(z)) + y * log(x);
},
[](complex<double> x, complex<double> y, complex<double> z) {
return log(log(z)) + x * log(y);
},
[](complex<double> x, complex<double> y, complex<double> z) {
return log(log(z)) + log(x) + log(y);
},
};
double xr, yr, zr;
cin >> xr >> yr >> zr;
complex<double> x = {xr, 0.0}, y = {yr, 0.0}, z = {zr, 0.0};
vector<complex<double>> results;
for (auto f : functors) results.push_back(f(x, y, z));
auto compareExponentsOf = [](complex<double> a, complex<double> b) -> bool {
double aSign = abs(a.imag()) > 0.001 ? -1.0 : 1.0;
double bSign = abs(b.imag()) > 0.001 ? -1.0 : 1.0;
if (aSign == bSign)
return (a.real() * aSign < b.real() * bSign);
else
return aSign < bSign;
};
auto maxIndex =
max_element(begin(results), end(results), compareExponentsOf) -
begin(results);
cout << formulas[maxIndex];
}
} // namespace mainns
using CurrentSolver = mainns::Solver621D;
int main() {
ios::sync_with_stdio(false);
CurrentSolver().run();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 0x7FFFFFFF;
const int MAX = 3;
const double eps = 1e-9;
struct Variable {
char key;
double value;
bool operator<(const Variable& var) const {
return key < var.key || (key == var.key && value < var.value);
}
};
Variable var[MAX];
char ans[100];
double f1() {
double x, y, z;
x = var[0].value;
y = var[1].value;
z = var[2].value;
return z * log(y) + log(log(x));
}
double f2() {
double x, y, z;
x = var[0].value;
y = var[1].value;
z = var[2].value;
return log(log(x)) + log(y) + log(z);
}
double f3() {
double x, y, z;
x = var[0].value;
y = var[1].value;
z = var[2].value;
return pow(x, pow(y, z));
}
double f4() {
double x, y, z;
x = var[0].value;
y = var[1].value;
z = var[2].value;
return pow(pow(x, y), z);
}
int main(int argc, char* args[]) {
double x, y, z;
double maxs1 = -INF;
cin >> x >> y >> z;
var[0].key = 'x';
var[0].value = x;
var[1].key = 'y';
var[1].value = y;
var[2].key = 'z';
var[2].value = z;
sort(var, var + 3);
ans[0] = '\0';
if (x > 16 || y > 16 || z > 16) {
do {
double val1 = f1();
double val2 = f2();
if (!isnan(val1) && (val1 - maxs1) > eps) {
maxs1 = val1;
sprintf(ans, "%c^%c^%c", var[0].key, var[1].key, var[2].key);
}
next_permutation(var, var + 3);
val1 = f1();
if (!isnan(val1) && (val1 - maxs1) > eps) {
maxs1 = val1;
sprintf(ans, "%c^%c^%c", var[0].key, var[1].key, var[2].key);
}
prev_permutation(var, var + 3);
if (!isnan(val2) && (val2 - maxs1) > eps) {
maxs1 = val2;
sprintf(ans, "(%c^%c)^%c", var[0].key, var[1].key, var[2].key);
}
next_permutation(var, var + 3);
val2 = f2();
if (!isnan(val2) && (val2 - maxs1) > eps) {
maxs1 = val2;
sprintf(ans, "(%c^%c)^%c", var[0].key, var[1].key, var[2].key);
}
} while (next_permutation(var, var + 3));
} else if (x <= 16 && y <= 16 && z <= 16) {
do {
double val1 = f3();
double val2 = f4();
if (!isnan(val1) && (val1 - maxs1) > eps) {
maxs1 = val1;
sprintf(ans, "%c^%c^%c", var[0].key, var[1].key, var[2].key);
}
next_permutation(var, var + 3);
val1 = f3();
if (!isnan(val1) && (val1 - maxs1) > eps) {
maxs1 = val1;
sprintf(ans, "%c^%c^%c", var[0].key, var[1].key, var[2].key);
}
prev_permutation(var, var + 3);
if (!isnan(val2) && (val2 - maxs1) > eps) {
maxs1 = val2;
sprintf(ans, "(%c^%c)^%c", var[0].key, var[1].key, var[2].key);
}
next_permutation(var, var + 3);
val2 = f4();
if (!isnan(val2) && (val2 - maxs1) > eps) {
maxs1 = val2;
sprintf(ans, "(%c^%c)^%c", var[0].key, var[1].key, var[2].key);
}
} while (next_permutation(var, var + 3));
}
puts(ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
const int MAXN = (int)2e6 + 7;
long double eps = 1e-11;
long double a[33];
int p[33];
void reconstruct(int id) {
vector<int> v;
if (id == 1) v = {0, 1, 2};
if (id == 2) v = {0, 2, 1};
if (id == 3) v = {0, 1, 2};
if (id == 4) v = {0, 2, 1};
if (id == 5) v = {1, 0, 2};
if (id == 6) v = {1, 2, 0};
if (id == 7) v = {1, 0, 2};
if (id == 8) v = {1, 2, 0};
if (id == 9) v = {2, 0, 1};
if (id == 10) v = {2, 1, 0};
if (id == 11) v = {2, 0, 1};
if (id == 12) v = {2, 1, 0};
for (int i = 0; i < 3; i++) p[i] = v[i];
}
string get(int id) {
string x = "x";
string y = "y";
string z = "z";
id--;
if (id / 4 == 1) {
x = "y";
y = "x";
z = "z";
}
if (id / 4 == 2) {
x = "z";
y = "x";
z = "y";
}
id %= 4;
if (id == 0) return x + "^" + y + "^" + z;
if (id == 1) return x + "^" + z + "^" + y;
if (id == 2) return "(" + x + "^" + y + ")" + "^" + z;
if (id == 3) return "(" + x + "^" + z + ")" + "^" + y;
while (true) {
}
}
int main() {
for (int i = 0; i < 3; i++) cin >> a[i];
for (int i = 0; i < 3; i++) p[i] = i;
pair<long double, int> ans;
for (int id = 1; id <= 12; id++) {
int block = (id - 1) / 2;
reconstruct(id);
long double x = a[p[0]];
long double y = a[p[1]];
long double z = a[p[2]];
long double first;
if (block % 2 == 1)
first = log(x) * y * z;
else
first = log(x) * pow(y, z);
if (id == 1)
ans = make_pair(first, id);
else {
if (abs(first - ans.first) < eps) continue;
if (first > ans.first) {
ans = make_pair(first, id);
}
}
}
cout << get(ans.second);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const long double eps = 1e-6;
const int mod = 1000000000 + 7;
const int INF = 1000000000;
const int maxn = 100;
int T, n, m;
double hehe, haha, ohoh;
long double x, y, z;
long double a[maxn];
bool eq(long double &x, long double &y) {
return abs(x - y) < eps || abs(x - y) < eps * abs(x);
}
int main() {
while (~scanf("%lf%lf%lf", &hehe, &haha, &ohoh)) {
x = hehe;
y = haha;
z = ohoh;
long double logx = log(x);
long double logy = log(y);
long double logz = log(z);
a[1] = logx * pow(y, z);
a[2] = logx * pow(z, y);
a[3] = logx * y * z;
a[4] = logx * z * y;
a[5] = logy * pow(x, z);
a[6] = logy * pow(z, x);
a[7] = logy * x * z;
a[8] = logy * z * x;
a[9] = logz * pow(x, y);
a[10] = logz * pow(y, x);
a[11] = logz * x * y;
a[12] = logz * y * x;
long double ans = a[1];
int id = 1;
for (int i = 2; i <= 12; i++) {
if (a[i] > ans && !eq(a[i], ans)) {
ans = a[i];
id = i;
}
}
if (id == 1)
printf("x^y^z\n");
else if (id == 2)
printf("x^z^y\n");
else if (id == 3)
printf("(x^y)^z\n");
else if (id == 5)
printf("y^x^z\n");
else if (id == 6)
printf("y^z^x\n");
else if (id == 7)
printf("(y^x)^z\n");
else if (id == 9)
printf("z^x^y\n");
else if (id == 10)
printf("z^y^x\n");
else if (id == 11)
printf("(z^x)^y\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int i, p;
long double x, y, z, Logx, Logy, Logz;
long double a[13];
string s[13];
int main() {
cin >> x >> y >> z;
Logx = log(x), Logy = log(y), Logz = log(z);
a[1] = Logx * pow(y, z), s[1] = "x^y^z";
a[2] = Logx * pow(z, y), s[2] = "x^z^y";
a[3] = Logx * y * z, s[3] = "(x^y)^z";
a[4] = Logx * z * y, s[4] = "(x^z)^y";
a[5] = Logy * pow(x, z), s[5] = "y^x^z";
a[6] = Logy * pow(z, x), s[6] = "y^z^x";
a[7] = Logy * x * z, s[7] = "(y^x)^z";
a[8] = Logy * z * x, s[8] = "(y^z)^x";
a[9] = Logz * pow(x, y), s[9] = "z^x^y";
a[10] = Logz * pow(y, x), s[10] = "z^y^x";
a[11] = Logz * x * y, s[11] = "(z^x)^y";
a[12] = Logz * y * x, s[12] = "(z^y)^x";
p = 1;
for (int i = 2; i <= 12; i++)
if (a[i] > a[p] + (long double)(1e-9)) p = i;
cout << s[p];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double x, y, z, r[15];
int main() {
std ::cin >> x >> y >> z;
int id = 1;
r[1] = pow(y, z) * log(x);
if (r[1] > r[id]) id = 1;
r[2] = pow(z, y) * log(x);
if (r[2] > r[id]) id = 2;
r[3] = y * z * log(x);
if (r[3] > r[id]) id = 3;
r[4] = y * z * log(x);
if (r[4] > r[id]) id = 4;
r[5] = pow(x, z) * log(y);
if (r[5] > r[id]) id = 5;
r[6] = pow(z, x) * log(y);
if (r[6] > r[id]) id = 6;
r[7] = x * z * log(y);
if (r[7] > r[id]) id = 7;
r[8] = x * z * log(y);
if (r[8] > r[id]) id = 8;
r[9] = pow(x, y) * log(z);
if (r[9] > r[id]) id = 9;
r[10] = pow(y, x) * log(z);
if (r[10] > r[id]) id = 10;
r[11] = x * y * log(z);
if (r[11] > r[id]) id = 11;
r[12] = x * y * log(z);
if (r[12] > r[id]) id = 12;
if (id == 1) puts("x^y^z");
if (id == 2) puts("x^z^y");
if (id == 3) puts("(x^y)^z");
if (id == 4) puts("(x^z)^y");
if (id == 5) puts("y^x^z");
if (id == 6) puts("y^z^x");
if (id == 7) puts("(y^x)^z");
if (id == 8) puts("(y^z)^x");
if (id == 9) puts("z^x^y");
if (id == 10) puts("z^y^x");
if (id == 11) puts("(z^x)^y");
if (id == 12) puts("(z^y)^x");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a[20];
double cal1(double x, double y, double z) {
double ans;
ans = z * log(y) + log(log(x));
return ans;
}
double cal2(double x, double y, double z) {
double ans;
ans = log(y) + log(z) + log(log(x));
return ans;
}
int solve(double x, double y, double z) {
for (int i = 1; i <= 12; i++) a[i] = -(1000000007);
if (x <= 1 && y <= 1 && z <= 1) {
double xx = 1.0 / x, yy = 1.0 / y, zz = 1.0 / z;
if (xx != 1) {
a[1] = cal1(xx, y, z);
a[2] = cal1(xx, z, y);
a[3] = cal2(xx, y, z);
a[4] = cal2(xx, z, y);
}
if (yy != 1) {
a[5] = cal1(yy, x, z);
a[6] = cal1(yy, z, x);
a[7] = cal2(yy, x, z);
a[8] = cal2(yy, z, x);
}
if (zz != 1) {
a[9] = cal1(zz, x, y);
a[10] = cal1(zz, y, x);
a[11] = cal2(zz, x, y);
a[12] = cal2(zz, y, x);
}
int re = 1;
double mmax = a[1];
for (int i = 1; i <= 12; i++) {
if (a[i] < mmax) mmax = a[i], re = i;
}
return re;
} else {
if (x > 1) {
a[1] = cal1(x, y, z);
a[2] = cal1(x, z, y);
a[3] = cal2(x, y, z);
a[4] = cal2(x, z, y);
}
if (y > 1) {
a[5] = cal1(y, x, z);
a[6] = cal1(y, z, x);
a[7] = cal2(y, x, z);
a[8] = cal2(y, z, x);
}
if (z > 1) {
a[9] = cal1(z, x, y);
a[10] = cal1(z, y, x);
a[11] = cal2(z, x, y);
a[12] = cal2(z, y, x);
}
}
int re = 1;
double mmax = a[1];
for (int i = 1; i <= 12; i++) {
if (a[i] > mmax) mmax = a[i], re = i;
}
return re;
}
int out[5];
void print(int mark) {
if (mark == 1) printf("x^y^z\n");
if (mark == 2) printf("x^z^y\n");
if (mark == 3) printf("(x^y)^z\n");
if (mark == 4) printf("(x^z)^y\n");
if (mark == 5) printf("y^x^z\n");
if (mark == 6) printf("y^z^x\n");
if (mark == 7) printf("(y^x)^z\n");
if (mark == 8) printf("(y^z)^x\n");
if (mark == 9) printf("z^x^y\n");
if (mark == 10) printf("z^y^x\n");
if (mark == 11) printf("(z^x)^y\n");
if (mark == 12) printf("(z^y)^x\n");
}
int main() {
double x, y, z;
while (cin >> x >> y >> z) {
int mark = solve(x, y, z);
print(mark);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long double x, y, z;
cin >> x >> y >> z;
long double a[13];
a[1] = log(x) * pow(y, z);
a[2] = log(x) * pow(z, y);
a[3] = y * z * log(x);
a[4] = log(y) * pow(x, z);
a[5] = log(y) * pow(z, x);
a[6] = x * z * log(y);
a[7] = log(z) * pow(x, y);
a[8] = log(z) * pow(y, x);
a[9] = x * y * log(z);
long double ans = a[1];
int m = 1;
for (int i = 2; i < 10; ++i) {
if (a[i] > ans) {
ans = a[i];
m = i;
}
}
if (m == 1) {
cout << "x^y^z\n";
}
if (m == 2) {
cout << "x^z^y\n";
}
if (m == 3) {
cout << "(x^y)^z\n";
}
if (m == 4) {
cout << "y^x^z\n";
}
if (m == 5) {
cout << "y^z^x\n";
}
if (m == 6) {
cout << "(y^x)^z\n";
}
if (m == 7) {
cout << "z^x^y\n";
}
if (m == 8) {
cout << "z^y^x\n";
}
if (m == 9) {
cout << "(z^x)^y\n";
}
return 0;
}
|
#include <bits/stdc++.h>
typedef long double (*fnt)(long double x, long double y, long double z);
using namespace std;
long double f1(long double x, long double y, long double z) {
return log(x) * pow(y, z);
}
long double f2(long double x, long double y, long double z) {
return log(x) * pow(z, y);
}
long double f3(long double x, long double y, long double z) {
return log(pow(x, y)) * z;
}
long double f4(long double x, long double y, long double z) {
return log(pow(x, z)) * y;
}
long double f5(long double x, long double y, long double z) {
return log(y) * pow(x, z);
}
long double f6(long double x, long double y, long double z) {
return log(y) * pow(z, x);
}
long double f7(long double x, long double y, long double z) {
return log(pow(y, x)) * z;
}
long double f8(long double x, long double y, long double z) {
return log(pow(y, z)) * x;
}
long double f9(long double x, long double y, long double z) {
return log(z) * pow(x, y);
}
long double f10(long double x, long double y, long double z) {
return log(z) * pow(y, x);
}
long double f11(long double x, long double y, long double z) {
return log(pow(z, x)) * y;
}
long double f12(long double x, long double y, long double z) {
return log(pow(z, y)) * x;
}
string str[15];
fnt A[15] = {f1, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12};
int main(int argc, char const *argv[]) {
str[1] = "x^y^z";
str[2] = "x^z^y";
str[3] = "(x^y)^z";
str[4] = "(x^z)^y";
str[5] = "y^x^z";
str[6] = "y^z^x";
str[7] = "(y^x)^z";
str[8] = "(y^z)^x";
str[9] = "z^x^y";
str[10] = "z^y^x";
str[11] = "(z^x)^y";
str[12] = "(z^y)^x";
long double x, y, z;
cin >> x >> y >> z;
int c = 1;
for (int i = 2; i < 13; i++) {
if (A[i](x, y, z) - 1e-9 > A[c](x, y, z)) {
c = i;
}
}
cout << str[c] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const long long INF = 1e9 + 47;
const long long LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int get(string s) {
int res = 0;
for (auto i : s)
if (i != '.') res = res * 10 + i - '0';
return res;
}
const long double EPS = 1e-6;
int cmp(long double x, long double y) {
if (abs(x - y) < EPS) return 0;
if (x < y)
return 1;
else
return -1;
}
pair<long double, int> get(long double x, long double y, long double z) {
if (abs(x - 1) < EPS) return {1.0, 1};
if (x > 1) {
long double pw = z * log(y);
int id = 1;
if (cmp(pw, y * log(z)) == 1) pw = y * log(z), id = 2;
if (cmp(pw, log(y) + log(z)) == 1) pw = log(y) + log(z), id = 3;
return {pw, id};
} else {
long double pw = z * log(y);
int id = 1;
if (cmp(pw, y * log(z)) == -1) pw = y * log(z), id = 2;
if (cmp(pw, log(y) + log(z)) == -1) pw = log(y) + log(z), id = 3;
return {pw, id};
}
}
int cmp(pair<long double, long double> x, pair<long double, long double> y) {
long double valx = log(x.first) * exp(x.second);
long double valy = log(y.first) * exp(y.second);
if (abs(valx - valy) < EPS) return 1;
return valx > valy;
}
void solve(int x) {
string s;
if (x == 1) s = "x^y^z";
if (x == 2) s = "x^z^y";
if (x == 3) s = "(x^y)^z";
if (x == 5) s = "y^x^z";
if (x == 6) s = "y^z^x";
if (x == 7) s = "(y^x)^z";
if (x == 9) s = "z^x^y";
if (x == 10) s = "z^y^x";
if (x == 11) s = "(z^x)^y";
cout << s << endl;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
string first, second, Z;
cin >> first >> second >> Z;
long double x = get(first) / 10.0;
long double y = get(second) / 10.0;
long double z = get(Z) / 10.0;
auto mxx = get(x, y, z);
auto mxy = get(y, x, z);
auto mxz = get(z, x, y);
if (cmp({x, mxx.first}, {y, mxy.first})) {
if (cmp({x, mxx.first}, {z, mxz.first}))
solve(mxx.second);
else
solve(mxz.second + 8);
} else {
if (cmp({y, mxy.first}, {z, mxz.first}))
solve(mxy.second + 4);
else
solve(mxz.second + 8);
}
cerr << "Time elapsed: " << clock() / (long double)CLOCKS_PER_SEC << endl;
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long double s[9];
string ans[9] = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long double x, y, z;
cin >> x >> y >> z;
long double tx, ty, tz;
tx = log(x);
ty = log(y);
tz = log(z);
s[0] = pow(y, z) * tx;
s[1] = pow(z, y) * tx;
s[2] = y * z * tx;
s[3] = pow(x, z) * ty;
s[4] = pow(z, x) * ty;
s[5] = x * z * ty;
s[6] = pow(x, y) * tz;
s[7] = pow(y, x) * tz;
s[8] = x * y * tz;
int maxi = 0;
for (int i = 1; i <= 8; i++) {
if (s[i] > s[maxi]) {
maxi = i;
}
}
cout << ans[maxi];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double X, Y, Z;
string S[13] = {
"", "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",
};
void solve() {
int i, j, k, l, r, x, y;
string s;
cin >> X >> Y >> Z;
pair<long double, int> P[9];
P[0] = {-log(X) * pow(Y, Z), 1};
P[1] = {-log(X) * pow(Z, Y), 2};
P[2] = {-log(X) * (Y * Z), 3};
P[3] = {-log(Y) * pow(X, Z), 5};
P[4] = {-log(Y) * pow(Z, X), 6};
P[5] = {-log(Y) * (X * Z), 7};
P[6] = {-log(Z) * pow(X, Y), 9};
P[7] = {-log(Z) * pow(Y, X), 10};
P[8] = {-log(Z) * (X * Y), 11};
sort(P, P + 9);
cout << S[P[0].second] << endl;
}
int main(int argc, char** argv) {
string s;
int i;
if (argc == 1) ios::sync_with_stdio(false);
for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long double x, y, z;
cin >> x >> y >> z;
long double best = -1000000;
int bestnum = 13;
if (x > 1 + 0.00001) {
if (z * log(y) + log(log(x)) - best > .000001) {
best = z * log(y) + log(log(x));
bestnum = 1;
}
if (y * log(z) + log(log(x)) - best > .000001) {
best = y * log(z) + log(log(x));
bestnum = 2;
}
if (log(y) + log(z) + log(log(x)) - best > .00001) {
best = log(y) + log(z) + log(log(x));
bestnum = 3;
}
}
if (y > 1 + .00001) {
if (z * log(x) + log(log(y)) - best > .000001) {
best = z * log(x) + log(log(y));
bestnum = 5;
}
if (x * log(z) + log(log(y)) - best > .000001) {
best = x * log(z) + log(log(y));
bestnum = 6;
}
if (log(x) + log(z) + log(log(y)) - best > .000001) {
best = log(x) + log(z) + log(log(y));
bestnum = 7;
}
}
if (z > 1 + .00001) {
if (y * log(x) + log(log(z)) - best > .000001) {
best = y * log(x) + log(log(z));
bestnum = 9;
}
if (x * log(y) + log(log(z)) - best > .000001) {
best = x * log(y) + log(log(z));
bestnum = 10;
}
if (log(x) + log(y) + log(log(z)) - best > .000001) {
best = log(x) + log(y) + log(log(z));
bestnum = 11;
}
}
if (bestnum == 13) {
if (pow(x, pow(y, z)) - best > .000001) {
bestnum = 1;
best = pow(x, pow(y, z));
}
if (pow(x, pow(z, y)) - best > .000001) {
bestnum = 2;
best = pow(x, pow(z, y));
}
if (pow(x, y * z) - best > .000001) {
bestnum = 3;
best = pow(x, y * z);
}
if (pow(y, pow(x, z)) - best > .000001) {
bestnum = 5;
best = pow(y, pow(x, z));
}
if (pow(y, pow(z, x)) - best > .000001) {
bestnum = 6;
best = pow(y, pow(z, x));
}
if (pow(y, x * z) - best > .000001) {
bestnum = 7;
best = pow(y, x * z);
}
if (pow(z, pow(x, y)) - best > .000001) {
bestnum = 9;
best = pow(z, pow(x, y));
}
if (pow(z, pow(y, x)) - best > .000001) {
bestnum = 10;
best = pow(z, pow(y, x));
}
if (pow(z, x * y) - best > .000001) {
bestnum = 11;
best = pow(z, x * y);
}
}
if (bestnum == 1) cout << "x^y^z" << endl;
if (bestnum == 2) cout << "x^z^y" << endl;
if (bestnum == 3) cout << "(x^y)^z" << endl;
if (bestnum == 5) cout << "y^x^z" << endl;
if (bestnum == 6) cout << "y^z^x" << endl;
if (bestnum == 7) cout << "(y^x)^z" << endl;
if (bestnum == 9) cout << "z^x^y" << endl;
if (bestnum == 10) cout << "z^y^x" << endl;
if (bestnum == 11) cout << "(z^x)^y" << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int maxn = 1e5 + 10;
long double a[20];
string s[] = {"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"};
int main() {
long double x, y, z;
while (cin >> x >> y >> z) {
a[0] = pow(y, z) * log(x);
a[1] = pow(z, y) * log(x);
a[2] = z * y * log(x);
a[3] = y * z * log(x);
a[4] = pow(x, z) * log(y);
a[5] = pow(z, x) * log(y);
a[6] = x * z * log(y);
a[7] = x * z * log(y);
a[8] = pow(x, y) * log(z);
a[9] = pow(y, x) * log(z);
a[10] = y * x * log(z);
a[11] = x * y * log(z);
int index = 0;
for (int i = 1; i < 12; ++i) {
if (a[i] > a[index]) {
index = i;
}
}
cout << s[index] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char* r[] = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
int main(int argc, char* argv[]) {
long double co[3];
cin >> co[0] >> co[1] >> co[2];
long double mxx = -1e200;
unsigned int ix = 0;
bool found = false;
for (unsigned int i = 0; i < 3; ++i) {
if (co[0] >= 1.) {
found = true;
long double cl = (fabs(1. - co[0]) <= 1E-11) ? -1e100 : logl(logl(co[0])),
lg[2];
lg[0] = logl(co[1]);
lg[1] = logl(co[2]);
long double fc[3];
fc[0] = co[2] * lg[0];
fc[1] = co[1] * lg[1];
fc[2] = lg[0] + lg[1];
long double mx = max(fc[0], max(fc[1], fc[2]));
unsigned int cx = 0;
if (mx == fc[0])
cx = 0;
else if (mx == fc[1])
cx = 1;
else
cx = 2;
long double cr = fc[cx] + cl;
if (cr > mxx) {
mxx = cr;
ix = (3 * i) + cx;
}
}
if (i == 0)
swap(co[0], co[1]);
else if (i == 1)
swap(co[0], co[2]);
}
if (!found) {
swap(co[0], co[1]);
swap(co[1], co[2]);
for (unsigned int i = 0; i < 3; ++i) {
long double fc[3];
fc[0] = powl(co[0], powl(co[1], co[2]));
fc[1] = powl(co[0], powl(co[2], co[1]));
fc[2] = powl(co[0], co[1] * co[2]);
long double mx = max(fc[0], max(fc[1], fc[2]));
unsigned int cx = 0;
if (mx == fc[0])
cx = 0;
else if (mx == fc[1])
cx = 1;
else
cx = 2;
if (fc[cx] > mxx) {
mxx = fc[cx];
ix = (3 * i) + cx;
}
if (i == 0)
swap(co[0], co[1]);
else if (i == 1)
swap(co[0], co[2]);
}
}
cout << r[ix] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const int Mod = 1e9 + 7;
const int maxn = 100000;
const long double eps = 1e-12;
long double x, y, z;
inline bool eq(const long double &x, const long double &y) {
return abs(x - y) < eps || abs(x - y) < eps * abs(x);
}
int main() {
{
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
x = a, y = b, z = c;
}
long double logx = log(x);
long double logy = log(y);
long double logz = log(z);
long double a[11];
a[0] = logx * pow(y, z);
a[1] = logx * pow(z, y);
a[2] = logx * y * z;
a[3] = a[2];
a[4] = logy * pow(x, z);
a[5] = logy * pow(z, x);
a[6] = logy * x * z;
a[7] = a[6];
a[8] = logz * pow(x, y);
a[9] = logz * pow(y, x);
a[10] = logz * x * y;
long double tmp = -1;
int ansp = -1;
for (int i = 0; i <= 11; i++)
if (!eq(a[i], tmp) && a[i] > tmp) {
tmp = a[i];
ansp = i;
}
if (ansp == 0) printf("x^y^z\n");
if (ansp == 1) printf("x^z^y\n");
if (ansp == 2) printf("(x^y)^z\n");
if (ansp == 4) printf("y^x^z\n");
if (ansp == 5) printf("y^z^x\n");
if (ansp == 6) printf("(y^x)^z\n");
if (ansp == 8) printf("z^x^y\n");
if (ansp == 9) printf("z^y^x\n");
if (ansp == 10) printf("(z^x)^y\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1.0e-12;
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",
};
struct data {
int type;
long double real;
long double imag;
bool operator<(const data& rhs) const {
if (type == 1 && rhs.type == 1) {
return real + eps < rhs.real;
}
return imag + eps < rhs.imag;
}
} a[12];
int main() {
long double x, y, z;
cin >> x >> y >> z;
for (int i = 0; i < 12; i++) {
a[i].type = 0;
}
a[0].imag = powl(y, z) * logl(x);
a[1].imag = powl(z, y) * logl(x);
a[2].imag = y * z * logl(x);
a[3].imag = z * y * logl(x);
a[4].imag = powl(x, z) * logl(y);
a[5].imag = powl(z, x) * logl(y);
a[6].imag = x * z * logl(y);
a[7].imag = z * x * logl(y);
a[8].imag = powl(x, y) * logl(z);
a[9].imag = powl(y, x) * logl(z);
a[10].imag = y * x * logl(z);
a[11].imag = x * y * logl(z);
if (logl(x) > 0) {
for (int i = 0; i < 4; i++) {
a[i].type = 1;
}
a[0].real = z * logl(y) + logl(logl(x));
a[1].real = y * logl(z) + logl(logl(x));
a[2].real = logl(y * z) + logl(logl(x));
a[3].real = logl(z * y) + logl(logl(x));
}
if (logl(y) > 0) {
for (int i = 4; i < 8; i++) {
a[i].type = 1;
}
a[4].real = z * logl(x) + logl(logl(y));
a[5].real = x * logl(z) + logl(logl(y));
a[6].real = logl(x * z) + logl(logl(y));
a[7].real = logl(z * x) + logl(logl(y));
}
if (logl(z) > 0) {
for (int i = 8; i < 12; i++) {
a[i].type = 1;
}
a[8].real = y * logl(x) + logl(logl(z));
a[9].real = x * logl(y) + logl(logl(z));
a[10].real = logl(y * x) + logl(logl(z));
a[11].real = logl(x * y) + logl(logl(z));
}
int pos = max_element(a, a + 12) - a;
puts(s[pos].c_str());
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 13;
long double x, y, z, a[MAX], b[MAX];
int main() {
cin >> x >> y >> z;
a[1] = x, b[1] = pow(y, z);
a[2] = x, b[2] = pow(z, y);
a[3] = x, b[3] = y * z;
a[4] = x, b[4] = z * y;
a[5] = y, b[5] = pow(x, z);
a[6] = y, b[6] = pow(z, x);
a[7] = y, b[7] = x * z;
a[8] = y, b[8] = z * x;
a[9] = z, b[9] = pow(x, y);
a[10] = z, b[10] = pow(y, x);
a[11] = z, b[11] = x * y;
a[12] = z, b[12] = y * x;
int ind = 1;
for (int i = 1; i <= 12; i++)
if (log(a[i]) * b[i] > log(a[ind]) * b[ind]) ind = i;
if (ind == 1) cout << "x^y^z";
if (ind == 2) cout << "x^z^y";
if (ind == 3) cout << "(x^y)^z";
if (ind == 4) cout << "(x^z)^y";
if (ind == 5) cout << "y^x^z";
if (ind == 6) cout << "y^z^x";
if (ind == 7) cout << "(y^x)^z";
if (ind == 8) cout << "(y^z)^x";
if (ind == 9) cout << "z^x^y";
if (ind == 10) cout << "z^y^x";
if (ind == 11) cout << "(z^x)^y";
if (ind == 12) cout << "(z^y)^x";
}
|
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
int main() {
long double x, y, z, a[20];
string s[20];
long double maxx;
int pos = 0;
s[1] = "x^y^z";
s[2] = "x^z^y";
s[3] = "(x^y)^z";
s[4] = "(x^z)^y";
s[5] = "y^x^z";
s[6] = "y^z^x";
s[7] = "(y^x)^z";
s[8] = "(y^z)^x";
s[9] = "z^x^y";
s[10] = "z^y^x";
s[11] = "(z^x)^y";
s[12] = "(z^y)^x";
cin >> x >> y >> z;
a[1] = log(x) * pow(y, z);
a[2] = log(x) * pow(z, y);
a[3] = log(x) * y * z;
a[4] = a[3];
a[5] = log(y) * pow(x, z);
a[6] = log(y) * pow(z, x);
a[7] = log(y) * x * z;
a[8] = a[7];
a[9] = log(z) * pow(x, y);
a[10] = log(z) * pow(y, x);
a[11] = log(z) * x * y;
a[12] = a[11];
maxx = a[1];
pos = 1;
for (int i = 2; i <= 12; i++) {
if (a[i] > maxx + eps) {
pos = i;
maxx = a[i];
}
}
cout << s[pos] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a, b, c;
long double ans[9];
void print(int x) {
if (x == 0) {
printf("x^y^z\n");
return;
}
if (x == 1) {
printf("x^z^y\n");
return;
}
if (x == 2) {
printf("(x^y)^z\n");
return;
}
if (x == 3) {
printf("y^x^z\n");
return;
}
if (x == 4) {
printf("y^z^x\n");
return;
}
if (x == 5) {
printf("(y^x)^z\n");
return;
}
if (x == 6) {
printf("z^x^y\n");
return;
}
if (x == 7) {
printf("z^y^x\n");
return;
}
if (x == 8) {
printf("(z^x)^y\n");
return;
}
}
int main() {
scanf("%lf%lf%lf", &a, &b, &c);
long double mx = -0x3f3f3f3f;
if (a <= 1 && b <= 1 && c <= 1) {
ans[0] = pow(a, pow(b, c));
ans[1] = pow(a, pow(c, b));
ans[2] = pow(pow(a, c), b);
ans[3] = pow(b, pow(a, c));
ans[4] = pow(b, pow(c, a));
ans[5] = pow(pow(b, a), c);
ans[6] = pow(c, pow(a, b));
ans[7] = pow(c, pow(b, a));
ans[8] = pow(pow(c, b), a);
} else {
ans[0] = c * log(b) + log(log(a));
ans[1] = b * log(c) + log(log(a));
ans[2] = log(b * c) + log(log(a));
ans[3] = c * log(a) + log(log(b));
ans[4] = a * log(c) + log(log(b));
ans[5] = log(a * c) + log(log(b));
ans[6] = b * log(a) + log(log(c));
ans[7] = a * log(b) + log(log(c));
ans[8] = log(a * b) + log(log(c));
}
int k = 0;
for (int i = 0; i < 9; i++) {
if (mx < ans[i] - 1e-10) {
mx = ans[i];
k = i;
}
}
print(k);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double Ans = -1 * 1e300, x, y, z, A[14];
int p;
int main() {
cin >> x >> y >> z;
A[1] = pow(y, z) * log(x);
A[2] = pow(z, y) * log(x);
A[3] = A[4] = z * y * log(x);
A[5] = pow(x, z) * log(y);
A[6] = pow(z, x) * log(y);
A[7] = A[8] = x * z * log(y);
A[9] = pow(x, y) * log(z);
A[10] = pow(y, x) * log(z);
A[11] = A[12] = x * y * log(z);
for (int i = 1; i <= 12; i++) {
if (A[i] > Ans) {
Ans = A[i];
p = i;
}
}
if (p == 1) cout << "x^y^z";
if (p == 2) cout << "x^z^y";
if (p == 3) cout << "(x^y)^z";
if (p == 4) cout << "(x^z)^y";
if (p == 5) cout << "y^x^z";
if (p == 6) cout << "y^z^x";
if (p == 7) cout << "(y^x)^z";
if (p == 8) cout << "(y^z)^x";
if (p == 9) cout << "z^x^y";
if (p == 10) cout << "z^y^x";
if (p == 11) cout << "(z^x)^y";
if (p == 12) cout << "(z^y)^x";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000007;
static const long long MODL = 1000000000000000003LL;
static const double eps = 1e-8;
template <class T>
inline T MIN(const T x, const T y) {
return (x < y) ? x : y;
}
template <class T>
inline T MAX(const T x, const T y) {
return (x > y) ? x : y;
}
template <class T>
inline void UPDMIN(T &x, const T y) {
if (x > y) x = y;
}
template <class T>
inline void UPDMAX(T &x, const T y) {
if (x < y) x = y;
}
template <class T>
inline int SIZE(const T &x) {
return (int)x.size();
}
template <class T>
inline int LENGTH(const T &x) {
return (int)x.length();
}
template <class T1, class T2>
inline pair<T1, T2> MP(const T1 &x, const T2 &y) {
return make_pair(x, y);
}
inline int BINT(const int x) { return 1 << x; }
inline long long BLLD(const int x) { return 1LL << x; }
inline int BINT_TEST(const int s, const int x) { return (s & BINT(x)) != 0; }
inline int BLLD_TEST(const long long s, const int x) {
return (s & BLLD(x)) != 0LL;
}
template <class T>
inline T LOWBIT(const T x) {
return (x ^ (x - 1)) & x;
}
template <class T>
inline int BITCOUNT(const T x) {
return (!x) ? x : (1 + BITCOUNT(x & (x - 1)));
}
const double PI = acos(-1.0);
const double EPS = 1e-5;
template <class T>
inline T SQR(const T x) {
return x * x;
}
template <class T1, class T2>
inline T1 POW(const T1 x, const T2 y) {
if (!y)
return 1;
else if ((y & 1) == 0) {
return SQR(POW(x, y >> 1));
} else
return POW(x, y ^ 1) * x;
}
template <class T>
inline T GCD(const T x, const T y) {
if (x < 0) return GCD(-x, y);
if (y < 0) return GCD(x, -y);
return (!y) ? x : GCD(y, x % y);
}
template <class T>
inline T LCM(const T x, const T y) {
if (x < 0) return LCM(-x, y);
if (y < 0) return LCM(x, -y);
return x * (y / GCD(x, y));
}
template <class T>
inline T EEA(const T a, const T b, T &x, T &y) {
if (a < 0) {
T d = EEA(-a, b, x, y);
x = -x;
return d;
}
if (b < 0) {
T d = EEA(a, -b, x, y);
y = -y;
return d;
}
if (!b) {
x = 1;
y = 0;
return a;
} else {
T d = EEA(b, a % b, x, y);
T t = x;
x = y;
y = t - (a / b) * y;
return d;
}
}
template <class T>
inline vector<pair<T, int> > FACTORIZE(T x) {
vector<pair<T, int> > ret;
if (x < 0) x = -x;
for (T i = 2; x > 1;) {
if (x % i == 0) {
int count = 0;
for (; x % i == 0; x /= i) count++;
ret.push_back(MP(i, count));
}
i++;
if (i > x / i) i = x;
}
return ret;
}
template <class T>
inline int ISPRIME(const T x) {
if (x <= 1) return 0;
for (T i = 2; SQR(i) <= x; i++)
if (x % i == 0) return 0;
return 1;
}
template <class T>
inline T EULARFUNCTION(T x) {
vector<pair<T, int> > f = FACTORIZE(x);
for (typename vector<pair<T, int> >::iterator it = f.begin(); it != f.end();
it++) {
x = x / it->first * (it->first - 1);
}
return x;
}
template <class T>
inline T INVERSEE(const T a, const T b = MOD) {
T x, y;
EEA(a, b, x, y);
return x ? x : 1;
}
template <class T>
inline T MOD_STD(const T x, const T m = MOD) {
return (x % m + m) % m;
}
template <class T>
inline void MOD_STD(T *x, const T m = MOD) {
*x = (*x % m + m) % m;
}
template <class T>
inline T MOD_ADD(const T x, const T y, const T m = MOD) {
return (x + y) % m;
}
template <class T>
inline void MOD_ADD(T *x, const T y, const T m = MOD) {
*x = (*x + y) % m;
}
template <class T>
inline T MOD_MUL(const T x, const T y, const T m = MOD) {
return (T)((1LL * x * y) % m);
}
template <class T>
inline void MOD_MUL(T *x, const T y, const T m = MOD) {
*x = (T)((1LL * (*x) * y) % m);
}
template <class T1, class T2>
inline T1 MOD_POW(const T1 x, const T2 y, const T1 m = MOD) {
if (y == 0)
return 1 % m;
else if ((y & 1) == 0) {
T1 z = MOD_POW(x, y >> 1, m);
return MOD_MUL(z, z, m);
} else
return MOD_MUL(MOD_POW(x, y ^ 1, m), x, m);
}
inline long long MODL_MUL(long long x, long long y, const long long m = MOD) {
if (x < y) swap(x, y);
long long z = 0LL;
while (y > 0) {
if (y & 1) {
MOD_ADD(&z, x, m);
}
MOD_ADD(&x, x, m);
y >>= 1;
}
return z;
}
inline long long MODL_POW(const long long x, const long long y,
const long long m = MOD) {
if (y == 0LL)
return 1LL % m;
else if ((y & 1) == 0LL) {
long long z = MODL_POW(x, y >> 1, m);
return MODL_MUL(z, z, m);
} else
return MODL_MUL(MODL_POW(x, y ^ 1, m), x, m);
}
template <class T>
class MATX {
private:
unsigned long hig, wid;
T *data;
void __init() {
this->data = (T *)malloc(sizeof(T) * this->hig * this->wid);
memset(this->data, 0, sizeof(T) * this->hig * this->wid);
}
public:
MATX() {
this->hig = this->wid = 1;
__init();
}
MATX(const unsigned long _len) {
this->hig = this->wid = _len;
__init();
}
MATX(const unsigned long _hig, const unsigned long _wid) {
this->hig = _hig;
this->wid = _wid;
__init();
}
MATX(const MATX &rhs) {
this->hig = rhs.hig;
this->wid = rhs.wid;
this->data = (T *)malloc(sizeof(T) * this->hig * this->wid);
for (unsigned long x = 0; x < this->hig; x++)
for (unsigned long y = 0; y < this->wid; y++)
this->data[x * this->wid + y] = rhs.at(x, y);
}
~MATX() { free(this->data); }
T &operator()(const unsigned long x, const unsigned long y) {
if (x >= this->hig || y >= this->wid) return (*(T *)NULL);
return this->data[x * wid + y];
}
MATX &operator=(const MATX &rhs) {
if (this->hig != rhs.hig || this->wid != rhs.wid) {
free(this->data);
this->hig = rhs.hig;
this->wid = rhs.wid;
this->data = (T *)malloc(sizeof(T) * this->hig * this->wid);
}
for (unsigned long x = 0; x < this->hig; x++)
for (unsigned long y = 0; y < this->wid; y++)
this->data[x * this->wid + y] = rhs.at(x, y);
return *this;
}
const MATX operator+(const MATX &opn) const {
MATX ret(*this);
for (unsigned long x = 0; x < ret.hig; x++)
for (unsigned long y = 0; y < ret.wid; y++)
ret.data[x * ret.wid + y] += opn.at(x, y);
return ret;
}
const MATX operator-(const MATX &opn) const {
MATX ret(*this);
for (unsigned long x = 0; x < ret.hig; x++)
for (unsigned long y = 0; y < ret.wid; y++)
ret.data[x * ret.wid + y] -= opn.at(x, y);
return ret;
}
const MATX operator*(const MATX &opn) const {
MATX ret(this->hig, opn.wid);
const unsigned long len = MIN(this->wid, opn.hig);
for (unsigned long x = 0; x < ret.hig; x++)
for (unsigned long y = 0; y < ret.wid; y++)
for (unsigned long z = 0; z < len; z++)
ret.data[x * ret.wid + y] += this->at(x, z) * opn.at(z, y);
return ret;
}
const MATX mul(const MATX &opn) const { return *this * opn; }
template <class T2>
const MATX mul(const MATX &opn, const T2 m) const {
MATX ret(this->hig, opn.wid);
const unsigned long len = MIN(this->wid, opn.wid);
for (unsigned long x = 0; x < ret.hig; x++)
for (unsigned long y = 0; y < ret.wid; y++)
for (unsigned long z = 0; z < len; z++)
MOD_ADD(&ret.data[x * ret.wid + y],
MOD_MUL(this->at(x, z), opn.at(z, y), m), m);
return ret;
}
MATX &operator+=(const MATX &rhs) {
*this = *this + rhs;
return *this;
}
MATX &operator-=(const MATX &rhs) {
*this = *this - rhs;
return *this;
}
MATX &operator*=(const MATX &rhs) {
*this = *this * rhs;
return *this;
}
const MATX pow(const unsigned long p) const {
MATX buff(*this), ret(this->hig, this->wid);
ret.set_one();
if (p > 0)
for (unsigned long i = 1;; i <<= 1) {
if (p & i) ret *= buff;
buff *= buff;
if (i > (p >> 1)) break;
}
return ret;
}
template <class T2>
const MATX pow(const unsigned long p, const T2 m) const {
MATX buff(*this), ret(this->hig, this->wid);
ret.set_one();
if (p > 0)
for (unsigned long i = 1;; i <<= 1) {
if (p & i) ret = ret.mul(buff, m);
buff = buff.mul(buff, m);
if (i > (p >> 1)) break;
}
return ret;
}
const T at(const unsigned long x, const unsigned long y) const {
if (x >= this->hig || y >= this->wid) return 0;
return this->data[x * wid + y];
}
void show() const {
for (unsigned long x = 0; x < this->hig; x++) {
for (unsigned long y = 0; y < this->wid; y++)
cout << this->at(x, y) << " ";
cout << endl;
}
}
void set_one() {
for (unsigned long x = 0; x < this->hig; x++)
for (unsigned long y = 0; y < this->wid; y++)
this->data[x * this->wid + y] = (x == y) ? 1 : 0;
}
};
template <class T>
class Complex {
public:
T r, i;
Complex(T x = 0.0, T y = 0.0) {
this->r = x;
this->i = y;
}
Complex operator+(const Complex &opn) const {
return Complex(this->r + opn.r, this->i + opn.i);
}
Complex operator-(const Complex &opn) const {
return Complex(this->r - opn.r, this->i - opn.i);
}
Complex operator*(const Complex &opn) const {
return Complex(this->r * opn.r - this->i * opn.i,
this->r * opn.i + this->i * opn.r);
}
};
class MILLERRABIN {
private:
static const int prime_table[12];
int witness(long long a, long long d, long long s, long long n) {
long long r = MODL_POW(a, d, n);
if (r == 1 || r == n - 1) return 0;
for (int i = 0; i < s - 1; i++) {
r = MODL_MUL(r, r, n);
if (r == 1) return 1;
if (r == n - 1) return 0;
}
return 1;
}
public:
int test(const long long n) {
if (n <= 2LL) return 0;
long long p = n - 1LL, s = 0LL;
while (!(p & 1)) {
p >>= 1;
s++;
}
for (int i = 0; i < 12 && this->prime_table[i] < n; i++) {
if (witness(this->prime_table[i], p, s, n)) return 0;
}
return 1;
}
};
const int MILLERRABIN::prime_table[12] = {2, 3, 5, 7, 11, 13,
17, 19, 23, 29, 31, 37};
template <class T>
inline int fsign(const T x) {
if (x > -eps && x < eps) return 0;
return (x < 0.0) ? -1 : 1;
}
template <class T>
class point_t {
public:
T x, y;
point_t() {
this->x = 0.0;
this->y = 0.0;
}
point_t(const T _x, const T _y) {
this->x = _x;
this->y = _y;
}
point_t operator-(const point_t &rhs) const {
return point_t(this->x - rhs.x, this->y - rhs.y);
}
T operator^(const point_t &rhs) const {
return this->x * rhs.y - this->y * rhs.x;
}
T operator*(const point_t &rhs) const {
return this->x * rhs.x + this->y * rhs.y;
}
T cross(const point_t &p, const point_t &q) const {
return (p - *this) ^ (q - *this);
}
void rotate(double radian) {
T x0 = x, y0 = y;
T sinr = sin(radian);
T cosr = cos(radian);
x = x0 * cosr - y0 * sinr;
y = x0 * sinr + y0 * cosr;
}
T dist2(const point_t &lhs, const point_t &rhs) const {
return (lhs - rhs) * (lhs - rhs);
}
T dist2(const point_t &rhs) const { return (*this - rhs) * (*this - rhs); }
T dist(const point_t &lhs, const point_t &rhs) const {
return sqrt((lhs - rhs) * (lhs - rhs));
}
T dist(const point_t &rhs) const {
return sqrt((*this - rhs) * (*this - rhs));
}
};
template <class T>
class segment_t {
public:
point_t<T> p, q;
segment_t() {
this->p.x = this->p.y = 0.0;
this->q.x = this->q.y = 0.0;
}
template <class T2>
segment_t(const point_t<T2> &_p, const point_t<T2> &_q) {
this->p.x = _p.x;
this->p.y = _p.y;
this->q.x = _q.x;
this->q.y = _q.y;
}
segment_t(const T px, const T py, const T qx, const T qy) {
this->p.x = px;
this->p.y = py;
this->q.x = qx;
this->q.y = qy;
}
T length() const { return this->p.dist(this->q); }
T length2() const { return this->p.dist2(this->q); }
int contain(const point_t<T> &pnt, const int ignore_endpoint = 0) const {
if (ignore_endpoint) {
return fsign((this->p - pnt) ^ (this->q - pnt)) == 0 &&
fsign((pnt.x - this->p.x) * (pnt.x - this->q.x)) < 0 &&
fsign((pnt.y - this->p.y) * (pnt.y - this->q.y)) < 0;
} else {
return fsign((this->p - pnt) ^ (this->q - pnt)) == 0 &&
fsign((pnt.x - this->p.x) * (pnt.x - this->q.x)) <= 0 &&
fsign((pnt.y - this->p.y) * (pnt.y - this->q.y)) <= 0;
}
}
int intersection(const segment_t &sa, const segment_t &sb,
const int ignore_endpoint = 0) const {
if (!ignore_endpoint) {
if (sa.contain(sb.p) || sa.contain(sb.q) || sb.contain(sa.p) ||
sb.contain(sa.q))
return 1;
}
return fsign(sa.p.cross(sa.q, sb.p)) * fsign(sa.p.cross(sa.q, sb.q)) < 0 &&
fsign(sb.p.cross(sb.q, sa.p)) * fsign(sb.p.cross(sb.q, sa.q)) < 0;
}
int intersection(const segment_t &rhs, const int ignore_endpoint = 0) const {
return this->intersection(*this, rhs, ignore_endpoint);
}
};
static const int pos0[6] = {0, 1, 4, 5, 8, 9};
static const int pos1[6] = {2, 3, 6, 7, 10, 11};
static const char res[12][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"};
double a[3], bst_val;
int c[3], bst_pos;
inline double type0(const double x, const double y, const double z) {
return log(y) * z + log(log(x));
}
inline double type1(const double x, const double y, const double z) {
return log(y * z) + log(log(x));
}
void mainasu_entry() {
for (int i = 0; i < 3; i++) c[i] = i;
int cnt = 0;
bst_val = 1e23;
do {
double buf;
if (a[c[0]] < 1.0 - eps) {
buf = type0(1.0 / a[c[0]], a[c[1]], a[c[2]]);
if (buf < bst_val - eps ||
(!fsign(buf - bst_val) && pos0[cnt] < bst_pos)) {
bst_val = buf;
bst_pos = pos0[cnt];
}
buf = type1(1.0 / a[c[0]], a[c[1]], a[c[2]]);
if (buf < bst_val - eps ||
(!fsign(buf - bst_val) && pos1[cnt] < bst_pos)) {
bst_val = buf;
bst_pos = pos1[cnt];
}
} else if (bst_val > -1e23 + eps) {
bst_val = -1e23 + eps;
bst_pos = pos0[cnt];
}
cnt++;
} while (next_permutation(c, c + 3));
}
void tsuika_entry() {
for (int i = 0; i < 3; i++) c[i] = i;
int cnt = 0;
bst_val = -1e23;
bst_pos = -1;
do {
double buf;
if (a[c[0]] > 1.0 + eps) {
buf = type0(a[c[0]], a[c[1]], a[c[2]]);
if (buf > bst_val + eps ||
(!fsign(buf - bst_val) && pos0[cnt] < bst_pos)) {
bst_val = buf;
bst_pos = pos0[cnt];
}
buf = type1(a[c[0]], a[c[1]], a[c[2]]);
if (buf > bst_val + eps ||
(!fsign(buf - bst_val) && pos1[cnt] < bst_pos)) {
bst_val = buf;
bst_pos = pos1[cnt];
}
}
cnt++;
} while (next_permutation(c, c + 3));
}
int main() {
ios::sync_with_stdio(false);
while (cin >> a[0] >> a[1] >> a[2]) {
if (a[0] < 1.0 + eps && a[1] < 1.0 + eps && a[2] < 1.0 + eps) {
mainasu_entry();
} else {
tsuika_entry();
}
cout << res[bst_pos] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int idx, use_pow = 0;
double m;
double results[12];
double x, y, z;
double chain(double a, double b, double c) {
if (use_pow) return pow(a, (double)pow(b, c));
if (a <= (double)1.0) return -1000000000;
return log10(log10(a)) + c * log10(b);
}
double parenthesis(double a, double b, double c) {
if (use_pow) return pow((double)pow(a, b), c);
if (a <= (double)1.0) return -1000000000;
return log10(log10(a)) + log10(b) + log10(c);
}
void output(int idx) {
switch (idx) {
case 1: {
cout << "x^y^z" << endl;
break;
}
case 2: {
cout << "x^z^y" << endl;
break;
}
case 3: {
cout << "(x^y)^z" << endl;
break;
}
case 4: {
cout << "(x^z)^y" << endl;
break;
}
case 5: {
cout << "y^x^z" << endl;
break;
}
case 6: {
cout << "y^z^x" << endl;
break;
}
case 7: {
cout << "(y^x)^z" << endl;
break;
}
case 8: {
cout << "(y^z)^x" << endl;
break;
}
case 9: {
cout << "z^x^y" << endl;
break;
}
case 10: {
cout << "z^y^x" << endl;
break;
}
case 11: {
cout << "(z^x)^y" << endl;
break;
}
case 12: {
cout << "(z^y)^x" << endl;
break;
}
}
}
void solve() {
results[0] = chain(x, y, z);
results[1] = chain(x, z, y);
results[2] = parenthesis(x, y, z);
results[3] = parenthesis(x, z, y);
results[4] = chain(y, x, z);
results[5] = chain(y, z, x);
results[6] = parenthesis(y, x, z);
results[7] = parenthesis(y, z, x);
results[8] = chain(z, x, y);
results[9] = chain(z, y, x);
results[10] = parenthesis(z, x, y);
results[11] = parenthesis(z, y, x);
m = results[0];
idx = 1;
for (int i = 0; i < 12; i++) {
if (results[i] - m > 1e-15) {
m = results[i];
idx = i + 1;
}
}
output(idx);
}
int main() {
cin >> x >> y >> z;
if (x <= 1 && y <= 1 && z <= 1) use_pow = 1;
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a1(double x, double y, double z) { return pow(y, z) * log(x); }
double b1(double x, double y, double z) { return z * log(y) + log(log(x)); }
double a2(double x, double z, double y) { return pow(y, z) * log(x); }
double b2(double x, double z, double y) { return z * log(y) + log(log(x)); }
double a5(double y, double x, double z) { return pow(y, z) * log(x); }
double b5(double y, double x, double z) { return z * log(y) + log(log(x)); }
double a6(double z, double x, double y) { return pow(y, z) * log(x); }
double b6(double z, double x, double y) { return z * log(y) + log(log(x)); }
double a9(double y, double z, double x) { return pow(y, z) * log(x); }
double b9(double y, double z, double x) { return z * log(y) + log(log(x)); }
double a10(double z, double y, double x) { return pow(y, z) * log(x); }
double b10(double z, double y, double x) { return z * log(y) + log(log(x)); }
double a3(double x, double y, double z) { return z * y * log(x); }
double b3(double x, double y, double z) { return log(z * y * log(x)); }
double a4(double x, double z, double y) { return z * y * log(x); }
double b4(double x, double z, double y) { return log(z * y * log(x)); }
double a7(double y, double x, double z) { return z * y * log(x); }
double b7(double y, double x, double z) { return log(z * y * log(x)); }
double a8(double z, double x, double y) { return z * y * log(x); }
double b8(double z, double x, double y) { return log(z * y * log(x)); }
double a11(double y, double z, double x) { return z * y * log(x); }
double b11(double y, double z, double x) { return log(z * y * log(x)); }
double a12(double z, double y, double x) { return z * y * log(x); }
double b12(double z, double y, double x) { return log(z * y * log(x)); }
double (*fa[])(double, double, double) = {a1, a2, a3, a4, a5, a6,
a7, a8, a9, a10, a11, a12};
double (*fb[])(double, double, double) = {b1, b2, b3, b4, b5, b6,
b7, b8, b9, b10, b11, b12};
const char *s[] = {"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"};
const double eps = 1e-7;
int main() {
double x, y, z;
scanf("%lf%lf%lf", &x, &y, &z);
double (**f)(double, double, double);
if (min(x, min(y, z)) > 1)
f = fb;
else
f = fa;
double a = -DBL_MAX, b;
int ans;
for (int i = 0; i < 12; i++)
if ((b = f[i](x, y, z)) - a > eps) a = b, ans = i;
puts(s[ans]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void get_a() {}
void output() {}
int main() {
long double x, y, z;
long double a[22];
cin >> x >> y >> z;
a[1] = log(x) * pow(y, z);
a[2] = log(x) * pow(z, y);
a[3] = y * z * log(x);
a[4] = log(y) * pow(x, z);
a[5] = log(y) * pow(z, x);
a[6] = x * z * log(y);
a[7] = log(z) * pow(x, y);
a[8] = log(z) * pow(y, x);
a[9] = x * y * log(z);
string str[] = {"", "x^y^z\n", "x^z^y\n", "(x^y)^z\n", "y^x^z\n",
"y^z^x\n", "(y^x)^z\n", "z^x^y\n", "z^y^x\n", "(z^x)^y\n"};
long double ans = a[1];
int m = 1;
for (int i = 2; i < 10; i++) {
if (a[i] > ans) {
ans = a[i];
m = i;
}
}
cout << str[m];
return 0;
}
|
#include <bits/stdc++.h>
const int SZ = 1e5 + 5;
using namespace std;
int main() {
long double x, y, z;
cin >> x >> y >> z;
string s[12];
vector<long double> v;
v.push_back(pow(y, z) * log(x));
s[0] = "x^y^z";
v.push_back(pow(z, y) * log(x));
s[1] = "x^z^y";
v.push_back(z * log(pow(x, y)));
s[2] = "(x^y)^z";
v.push_back(y * log(pow(x, z)));
s[3] = "(x^z)^y";
v.push_back(pow(x, z) * log(y));
s[4] = "y^x^z";
v.push_back(pow(z, x) * log(y));
s[5] = "y^z^x";
v.push_back(z * log(pow(y, x)));
s[6] = "(y^x)^z";
v.push_back(x * log(pow(y, z)));
s[7] = "(y^z)^x";
v.push_back(pow(x, y) * log(z));
s[8] = "z^x^y";
v.push_back(pow(y, x) * log(z));
s[9] = "z^y^x";
v.push_back(y * log(pow(z, x)));
s[10] = "(z^x)^y";
v.push_back(x * log(pow(z, y)));
s[11] = "(z^y)^x";
int idx = 0;
for (int i = 1; i < 12; i++)
if (v[i] - v[idx] > 1e-9) idx = i;
cout << s[idx];
}
|
#include <bits/stdc++.h>
using namespace std;
char str[12][10] = {
"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 x, y, z;
long double mx, t;
int pos;
void judge(int x) {
if (fabs(mx - t) <= 1e-6)
return;
else if (mx < t) {
pos = x;
mx = t;
}
}
int main() {
cin >> x >> y >> z;
pos = 0;
mx = pow(y, z) * log(x);
t = pow(z, y) * log(x);
judge(1);
t = z * log(pow(x, y));
judge(2);
t = y * log(pow(x, z));
judge(3);
t = pow(x, z) * log(y);
judge(4);
t = pow(z, x) * log(y);
judge(5);
t = z * log(pow(y, x));
judge(6);
t = x * log(pow(y, z));
judge(7);
t = pow(x, y) * log(z);
judge(8);
t = pow(y, x) * log(z);
judge(9);
t = y * log(pow(z, x));
judge(10);
t = x * log(pow(z, y));
judge(11);
printf("%s\n", str[pos]);
}
|
#include <bits/stdc++.h>
using namespace std;
string S[] = {"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"};
int ans;
long double Max;
void cmp1(long double x, long double y, long double z, int l) {
long double tmp = logl(x) * pow(y, z);
if (tmp > Max) {
Max = tmp;
ans = l;
}
}
void cmp2(long double x, long double y, long double z, int l) {
long double tmp = logl(x) * y * z;
if (tmp > Max) {
Max = tmp;
ans = l;
}
}
int main() {
long double x, y, z;
cin >> x >> y >> z;
Max = logl(x) * pow(y, z);
cmp1(x, z, y, 1);
cmp2(x, y, z, 2);
cmp1(y, x, z, 4);
cmp1(y, z, x, 5);
cmp2(y, x, z, 6);
cmp1(z, x, y, 8);
cmp1(z, y, x, 9);
cmp2(z, x, y, 10);
cout << S[ans] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double x, y, z;
long double arr[9];
string s[9] = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
int main(void) {
cin >> x >> y >> z;
arr[0] = pow(y, z) * log(x);
arr[1] = pow(z, y) * log(x);
arr[2] = y * z * log(x);
arr[3] = pow(x, z) * log(y);
arr[4] = pow(z, x) * log(y);
arr[5] = x * z * log(y);
arr[6] = pow(x, y) * log(z);
arr[7] = pow(y, x) * log(z);
arr[8] = x * y * log(z);
int ind = 0;
for (int i = 0; i < 9; i++) {
if (arr[i] > arr[ind]) ind = i;
}
cout << s[ind] << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
long double x, y, z, s = -10;
cin >> x >> y >> z;
vector<pair<long double, string>> a(12);
a[0].first = pow(y, z) * log(x);
a[1].first = pow(z, y) * log(x);
a[2].first = a[3].first = (y * z) * log(x);
a[4].first = pow(x, z) * log(y);
a[5].first = pow(z, x) * log(y);
a[6].first = (x * z) * log(y);
a[7].first = (x * z) * log(y);
a[8].first = pow(x, y) * log(z);
a[9].first = pow(y, x) * log(z);
a[11].first = a[10].first = (y * x) * log(z);
a[0].second = "x^y^z";
a[1].second = "x^z^y";
a[2].second = "(x^y)^z";
a[3].second = "(x^z)^y";
a[4].second = "y^x^z";
a[5].second = "y^z^x";
a[6].second = "(y^x)^z";
a[7].second = "(y^z)^x";
a[8].second = "z^x^y";
a[9].second = "z^y^x";
a[10].second = "(z^x)^y";
a[11].second = "(z^y)^x";
int id = 0;
for (int i = 0; i < 12; i++)
if (s < a[i].first) {
s = a[i].first;
id = i;
}
cout << a[id].second;
}
|
#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const int Mod = 1e9 + 7;
const int maxn = 100000;
const long double eps = 1e-12;
long double x, y, z;
inline bool eq(const long double &x, const long double &y) {
return abs(x - y) < eps || abs(x - y) < eps * abs(x);
}
int main() {
{
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
x = a, y = b, z = c;
}
long double logx = log(x);
long double logy = log(y);
long double logz = log(z);
long double a[11];
a[0] = logx * pow(y, z);
a[1] = logx * pow(z, y);
a[2] = logx * y * z;
a[3] = a[2];
a[4] = logy * pow(x, z);
a[5] = logy * pow(z, x);
a[6] = logy * x * z;
a[7] = a[6];
a[8] = logz * pow(x, y);
a[9] = logz * pow(y, x);
a[10] = logz * x * y;
long double tmp = -1;
int ansp = -1;
for (int i = 0; i <= 11; i++)
if (!eq(a[i], tmp) && a[i] > tmp) {
tmp = a[i];
ansp = i;
}
if (ansp == 0) printf("x^y^z\n");
if (ansp == 1) printf("x^z^y\n");
if (ansp == 2) printf("(x^y)^z\n");
if (ansp == 4) printf("y^x^z\n");
if (ansp == 5) printf("y^z^x\n");
if (ansp == 6) printf("(y^x)^z\n");
if (ansp == 8) printf("z^x^y\n");
if (ansp == 9) printf("z^y^x\n");
if (ansp == 10) printf("(z^x)^y\n");
return 0;
}
|
#include <bits/stdc++.h>
int setBit(int N, int pos) { return N = N | (1 << pos); }
int resetBit(int N, int pos) { return N = N & ~(1 << pos); }
bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); }
using namespace std;
long double x, y, z;
int main() {
string ans = "x^y^z";
while (cin >> x >> y >> z) {
long double mx = powl(y, z) * log(x) - 1e-12 - 1e-12;
if (powl(y, z) * log(x) > mx + 1e-12) {
ans = "x^y^z";
mx = powl(y, z) * log(x);
}
if (powl(z, y) * log(x) > mx + 1e-12) {
ans = "x^z^y";
mx = powl(z, y) * log(x);
}
if (y * z * log(x) > mx + 1e-12) {
ans = "(x^y)^z";
mx = y * z * log(x);
}
if (powl(x, z) * log(y) > mx + 1e-12) {
ans = "y^x^z";
mx = powl(x, z) * log(y);
}
if (powl(z, x) * log(y) > mx + 1e-12) {
ans = "y^z^x";
mx = powl(z, x) * log(y);
}
if (x * z * log(y) > mx + 1e-12) {
ans = "(y^x)^z";
mx = x * z * log(y);
}
if (powl(x, y) * log(z) > mx + 1e-12) {
ans = "z^x^y";
mx = powl(x, y) * log(z);
}
if (powl(y, x) * log(z) > mx + 1e-12) {
ans = "z^y^x";
mx = powl(y, x) * log(z);
}
if (x * y * log(z) > mx + 1e-12) {
ans = "(z^x)^y";
mx = x * y * log(z);
}
puts(ans.c_str());
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
struct Sync_stdio {
Sync_stdio() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
}
} _sync_stdio;
double EPS = 1e-7;
vector<string> v = {"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 solve1(long double a, long double b, long double c) {
return pow(b, c) * log(a);
}
long double solve2(long double a, long double b, long double c) {
return c * b * log(a);
}
void naive(long double a, long double b, long double c) {
int idx = 0;
long double best = -1e19;
for (int i = (0); i < (3); ++i) {
if (i == 1) {
swap(a, b);
} else if (i == 2) {
swap(a, c);
}
if (solve1(a, b, c) > best + EPS) {
idx = 0 + i * 4;
best = solve1(a, b, c);
}
if (solve1(a, c, b) > best + EPS) {
idx = 1 + i * 4;
best = solve1(a, c, b);
}
if (solve2(a, b, c) > best + EPS) {
idx = 2 + i * 4;
best = solve2(a, b, c);
}
if (solve2(a, c, b) > best + EPS) {
idx = 3 + i * 4;
best = solve2(a, c, b);
}
}
cout << v[idx];
exit(0);
}
int main() {
double a, b, c;
cin >> a >> b >> c;
naive(a, b, c);
}
|
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-12;
inline bool eq(const long double &x, const long double &y) {
return abs(x - y) < eps || abs(x - y) < eps * abs(x);
}
int main() {
long double x, y, z;
{
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
x = a, y = b, z = c;
}
long double logx = log(x);
long double logy = log(y);
long double logz = log(z);
long double a[11];
a[0] = logx * pow(y, z);
a[1] = logx * pow(z, y);
a[2] = logx * y * z;
a[3] = a[2];
a[4] = logy * pow(x, z);
a[5] = logy * pow(z, x);
a[6] = logy * x * z;
a[7] = a[6];
a[8] = logz * pow(x, y);
a[9] = logz * pow(y, x);
a[10] = logz * x * y;
long double tmp = -1;
int ansp = -1;
for (int _n(11), i(0); i < _n; i++)
if (!eq(a[i], tmp) && a[i] > tmp) {
tmp = a[i];
ansp = i;
}
if (ansp == 0) printf("x^y^z\n");
if (ansp == 1) printf("x^z^y\n");
if (ansp == 2) printf("(x^y)^z\n");
if (ansp == 4) printf("y^x^z\n");
if (ansp == 5) printf("y^z^x\n");
if (ansp == 6) printf("(y^x)^z\n");
if (ansp == 8) printf("z^x^y\n");
if (ansp == 9) printf("z^y^x\n");
if (ansp == 10) printf("(z^x)^y\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int INF = 0x3f3f3f3f;
long long mod = 1e9 + 7;
int main() {
string s[13] = {
"", "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",
};
int ans = 1;
double x, y, z;
double mx = -10000, t;
double eps = 1e-9;
cin >> x >> y >> z;
if (x <= 1 && y <= 1 && z <= 1) {
ans = 1;
mx = pow(x, pow(y, z));
t = pow(x, pow(z, y));
if (t > mx + eps) {
mx = t;
ans = 2;
}
t = pow(pow(x, y), z);
if (t > mx + eps) {
mx = t;
ans = 3;
}
t = pow(y, pow(x, z));
if (t > mx + eps) {
mx = t;
ans = 5;
}
t = pow(y, pow(z, x));
if (t > mx + eps) {
mx = t;
ans = 6;
}
t = pow(pow(y, x), z);
if (t > mx + eps) {
mx = t;
ans = 7;
}
t = pow(z, pow(x, y));
if (t > mx + eps) {
mx = t;
ans = 9;
}
t = pow(z, pow(y, x));
if (t > mx + eps) {
mx = t;
ans = 10;
}
t = pow(pow(z, x), y);
if (t > mx + eps) {
mx = t;
ans = 11;
}
} else {
if (x > 1) {
t = z * log(y) + log(log(x));
if (t > mx + eps) {
mx = t;
ans = 1;
}
t = y * log(z) + log(log(x));
if (t > mx + eps) {
mx = t;
ans = 2;
}
t = log(y) + log(z) + log(log(x));
if (t > mx + eps) {
mx = t;
ans = 3;
}
}
if (y > 1) {
t = z * log(x) + log(log(y));
if (t > mx + eps) {
mx = t;
ans = 5;
}
t = x * log(z) + log(log(y));
if (t > mx + eps) {
mx = t;
ans = 6;
}
t = log(x) + log(z) + log(log(y));
if (t > mx + eps) {
mx = t;
ans = 7;
}
}
if (z > 1) {
t = y * log(x) + log(log(z));
if (t > mx + eps) {
mx = t;
ans = 9;
}
t = x * log(y) + log(log(z));
if (t > mx + eps) {
mx = t;
ans = 10;
}
t = log(x) + log(y) + log(log(z));
if (t > mx + eps) {
mx = t;
ans = 11;
}
}
}
cout << s[ans] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const char s[12][10] = {"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"};
int main() {
long double a[12];
long double x, 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[10] = a[11] = x * y * log(z);
int pos = 0;
for (int i = 1; i < 12; i++)
if (a[i] > a[pos]) pos = i;
printf("%s\n", s[pos]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double x, y, z;
vector<pair<long double, int> > V;
void Print(int x) {
switch (x) {
case 1:
printf("x^y^z\n");
break;
case 2:
printf("x^z^y\n");
break;
case 3:
printf("(x^y)^z\n");
break;
case 5:
printf("y^x^z\n");
break;
case 6:
printf("y^z^x\n");
break;
case 7:
printf("(y^x)^z\n");
break;
case 9:
printf("z^x^y");
break;
case 10:
printf("z^y^x");
break;
case 11:
printf("(z^x)^y");
break;
}
}
int main() {
cin >> x >> y >> z;
long double mx = max(max(x, y), z);
if (mx > 1.0l) {
if (x > 1.0l) {
V.push_back(pair<long double, int>(-(z * log(y) + log(log(x))), 1));
V.push_back(pair<long double, int>(-(y * log(z) + log(log(x))), 2));
V.push_back(pair<long double, int>(-(log(y * z) + log(log(x))), 3));
}
if (y > 1.0l) {
V.push_back(pair<long double, int>(-(z * log(x) + log(log(y))), 5));
V.push_back(pair<long double, int>(-(x * log(z) + log(log(y))), 6));
V.push_back(pair<long double, int>(-(log(x * z) + log(log(y))), 7));
}
if (z > 1.0l) {
V.push_back(pair<long double, int>(-(y * log(x) + log(log(z))), 9));
V.push_back(pair<long double, int>(-(x * log(y) + log(log(z))), 10));
V.push_back(pair<long double, int>(-(log(x * y) + log(log(z))), 11));
}
sort(V.begin(), V.end());
Print(V[0].second);
return 0;
}
if (mx == 1.0l) {
if (x == 1.0l)
Print(1);
else if (y == 1.0l)
Print(5);
else if (z == 1.0l)
Print(9);
return 0;
}
V.push_back(pair<long double, int>((z * log(y) + log(-log(x))), 1));
V.push_back(pair<long double, int>((y * log(z) + log(-log(x))), 2));
V.push_back(pair<long double, int>((log(y * z) + log(-log(x))), 3));
V.push_back(pair<long double, int>((z * log(x) + log(-log(y))), 5));
V.push_back(pair<long double, int>((x * log(z) + log(-log(y))), 6));
V.push_back(pair<long double, int>((log(x * z) + log(-log(y))), 7));
V.push_back(pair<long double, int>((y * log(x) + log(-log(z))), 9));
V.push_back(pair<long double, int>((x * log(y) + log(-log(z))), 10));
V.push_back(pair<long double, int>((log(x * y) + log(-log(z))), 11));
sort(V.begin(), V.end());
Print(V[0].second);
return 0;
return 0;
}
|
#include <bits/stdc++.h>
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
string ans[12];
long double eps = 1e-7;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ans[0] = "x^y^z", ans[1] = "x^z^y", ans[2] = "(x^y)^z", ans[3] = "(x^z)^y";
ans[4] = "y^x^z", ans[5] = "y^z^x", ans[6] = "(y^x)^z", ans[7] = "(y^z)^x";
ans[8] = "z^x^y", ans[9] = "z^y^x", ans[10] = "(z^x)^y", ans[11] = "(z^y)^x";
long double x, y, z;
cin >> x >> y >> z;
vector<long double> num(12);
num[0] = powl(y, z) * log(x);
num[1] = powl(z, y) * log(x);
num[2] = y * z * log(x);
num[4] = powl(x, z) * log(y);
num[5] = powl(z, x) * log(y);
num[6] = x * z * log(y);
num[8] = powl(x, y) * log(z);
num[9] = powl(y, x) * log(z);
num[10] = x * y * log(z);
int index = 0;
for (int i = 1; i < 12; i++) {
if (i % 4 == 3) continue;
if (num[index] < num[i]) index = i;
}
cout << ans[index] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long double EPS = 1e-8;
bool comp(pair<long double, int> p1, pair<long double, int> p2) {
if (p1.first != p2.first) return p1.first < p2.first;
return p1.second > p2.second;
}
int main() {
double x, y, z;
cin >> x >> y >> z;
string ans[] = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
vector<pair<long double, int>> val(9);
if (x > 1.0 || y > 1.0 || z > 1.0) {
if (x > 1.0) {
val[0] = make_pair(z * log(y) + log(log(x)), 0);
val[1] = make_pair(y * log(z) + log(log(x)), 1);
val[2] = make_pair(log(y * z) + log(log(x)), 2);
} else {
val[0] = make_pair(-INF, 0);
val[1] = make_pair(-INF, 1);
val[2] = make_pair(-INF, 2);
}
if (y > 1.0) {
val[3] = make_pair(z * log(x) + log(log(y)), 3);
val[4] = make_pair(x * log(z) + log(log(y)), 4);
val[5] = make_pair(log(z * x) + log(log(y)), 5);
} else {
val[3] = make_pair(-INF, 3);
val[4] = make_pair(-INF, 4);
val[5] = make_pair(-INF, 5);
}
if (z > 1.0) {
val[6] = make_pair(y * log(x) + log(log(z)), 6);
val[7] = make_pair(x * log(y) + log(log(z)), 7);
val[8] = make_pair(log(y * x) + log(log(z)), 8);
} else {
val[6] = make_pair(-INF, 6);
val[7] = make_pair(-INF, 7);
val[8] = make_pair(-INF, 8);
}
} else {
val[0] = make_pair(pow(y, z) * log(x), 0);
val[1] = make_pair(pow(z, y) * log(x), 1);
val[2] = make_pair(y * z * log(x), 2);
val[3] = make_pair(pow(x, z) * log(y), 3);
val[4] = make_pair(pow(z, x) * log(y), 4);
val[5] = make_pair(x * z * log(y), 5);
val[6] = make_pair(pow(x, y) * log(z), 6);
val[7] = make_pair(pow(y, x) * log(z), 7);
val[8] = make_pair(x * y * log(z), 8);
}
sort((val).begin(), (val).end(), comp);
cout << ans[val[8].second] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double ta;
long double x[3], eps = 1e-10, y, z, w;
int main() {
for (int a = 0; a < 3; a++) {
scanf("%lf", &ta);
x[a] = ta;
}
y = pow(x[1], x[2]) * log2l(x[0]);
z = 0;
w = pow(x[2], x[1]) * log2l(x[0]);
if (w > y + eps) {
y = w;
z = 1;
}
w = x[1] * x[2] * log2l(x[0]);
if (w > y + eps) {
y = w;
z = 2;
}
w = pow(x[0], x[2]) * log2l(x[1]);
if (w > y + eps) {
y = w;
z = 4;
}
w = pow(x[2], x[0]) * log2l(x[1]);
if (w > y + eps) {
y = w;
z = 5;
}
w = x[0] * x[2] * log2l(x[1]);
if (w > y + eps) {
y = w;
z = 6;
}
w = pow(x[0], x[1]) * log2l(x[2]);
if (w > y + eps) {
y = w;
z = 8;
}
w = pow(x[1], x[0]) * log2l(x[2]);
if (w > y + eps) {
y = w;
z = 9;
}
w = x[0] * x[1] * log2l(x[2]);
if (w > y + eps) {
y = w;
z = 10;
}
if (z == 0) printf("x^y^z");
if (z == 1) printf("x^z^y");
if (z == 2) printf("(x^y)^z");
if (z == 4) printf("y^x^z");
if (z == 5) printf("y^z^x");
if (z == 6) printf("(y^x)^z");
if (z == 8) printf("z^x^y");
if (z == 9) printf("z^y^x");
if (z == 10) printf("(z^x)^y");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct node {
int id;
string n;
double x;
bool operator<(const node& tt) const {
if (x == tt.x) return id < tt.id;
return x < tt.x;
}
} t[15];
double x, y, z;
void solve1() {
int cc = 0;
if (x >= 1) {
t[cc].id = cc;
t[cc].n = "x^y^z";
t[cc++].x = z * log(y) + log(log(x));
t[cc].id = cc;
t[cc].n = "x^z^y";
t[cc++].x = y * log(z) + log(log(x));
t[cc].id = cc;
t[cc].n = "(x^y)^z";
t[cc++].x = log(z) + log(y) + log(log(x));
}
if (y >= 1) {
t[cc].id = cc;
t[cc].n = "y^x^z";
t[cc++].x = z * log(x) + log(log(y));
t[cc].id = cc;
t[cc].n = "y^z^x";
t[cc++].x = x * log(z) + log(log(y));
t[cc].id = cc;
t[cc].n = "(y^x)^z";
t[cc++].x = log(x) + log(z) + log(log(y));
}
if (z >= 1) {
t[cc].id = cc;
t[cc].n = "z^x^y";
t[cc++].x = y * log(x) + log(log(z));
t[cc].id = cc;
t[cc].n = "z^y^x";
t[cc++].x = x * log(y) + log(log(z));
t[cc].id = cc;
t[cc].n = "(z^x)^y";
t[cc++].x = log(x) + log(y) + log(log(z));
}
sort(t, t + cc);
--cc;
--cc;
while (cc >= 0 && t[cc].x == t[cc + 1].x) --cc;
if (t[cc].x != t[cc + 1].x) ++cc;
printf("%s\n", t[cc].n.c_str());
}
void solve2() {
int cc = 0;
t[cc].id = cc;
t[cc].n = "x^y^z";
t[cc++].x = z * log(y) + log(log(1 / x));
t[cc].id = cc;
t[cc].n = "x^z^y";
t[cc++].x = y * log(z) + log(log(1 / x));
t[cc].id = cc;
t[cc].n = "(x^y)^z";
t[cc++].x = log(z) + log(y) + log(log(1 / x));
t[cc].id = cc;
t[cc].n = "y^x^z";
t[cc++].x = z * log(x) + log(log(1 / y));
t[cc].id = cc;
t[cc].n = "y^z^x";
t[cc++].x = x * log(z) + log(log(1 / y));
t[cc].id = cc;
t[cc].n = "(y^x)^z";
t[cc++].x = log(x) + log(z) + log(log(1 / y));
t[cc].id = cc;
t[cc].n = "z^x^y";
t[cc++].x = y * log(x) + log(log(1 / z));
t[cc].id = cc;
t[cc].n = "z^y^x";
t[cc++].x = x * log(y) + log(log(1 / z));
t[cc].id = cc;
t[cc].n = "(z^x)^y";
t[cc++].x = log(x) + log(y) + log(log(1 / z));
sort(t, t + cc);
printf("%s\n", t[0].n.c_str());
}
int main() {
scanf("%lf%lf%lf", &x, &y, &z);
if (x < 1 && y < 1 && z < 1)
solve2();
else
solve1();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double x, y, z;
long double num[50];
char s[15][15] = {" ", "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"};
int main() {
while (cin >> x >> y >> z) {
long double maxn = -1;
char ans[15];
num[1] = pow(y, z) * log(x);
num[2] = pow(z, y) * log(x);
num[3] = y * z * log(x);
num[4] = y * z * log(x);
num[5] = pow(x, z) * log(y);
num[6] = pow(z, x) * log(y);
num[7] = x * z * log(y);
num[8] = x * z * log(y);
num[9] = pow(x, y) * log(z);
num[10] = pow(y, x) * log(z);
num[11] = x * y * log(z);
num[12] = x * y * log(z);
for (int i = 1; i <= 12; i++) {
if (num[i] > maxn) {
maxn = num[i];
strcpy(ans, s[i]);
}
}
cout << ans << endl;
}
}
|
#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 ans[15];
int main() {
long double x, y, z;
cin >> x >> y >> z;
long double xx = logl(x);
long double yy = logl(y);
long double zz = logl(z);
ans[1] = xx * powl(y, z);
ans[2] = xx * powl(z, y);
ans[3] = xx * y * z;
ans[4] = xx * y * z;
ans[5] = yy * powl(x, z);
ans[6] = yy * powl(z, x);
ans[7] = yy * x * z;
ans[8] = yy * x * z;
ans[9] = zz * powl(x, y);
ans[10] = zz * powl(y, x);
ans[11] = zz * x * y;
ans[12] = zz * y * x;
int j = 1;
long double sum = ans[1];
for (int i = 1; i <= 12; i++) {
if (sum < ans[i]) {
sum = ans[i];
j = i;
}
}
cout << s[j - 1] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long double x, y, z;
cin >> x >> y >> z;
string s[12];
s[0] = "x^y^z", s[1] = "x^z^y", s[2] = "(x^y)^z", s[3] = "(x^z)^y";
s[4] = "y^x^z", s[5] = "y^z^x", s[6] = "(y^x)^z", s[7] = "(y^z)^x";
s[8] = "z^x^y", s[9] = "z^y^x", s[10] = "(z^x)^y", s[11] = "(z^y)^x";
long double a[12];
long double lx = log(x);
long double ly = log(y);
long double lz = log(z);
a[0] = lx * pow(y, z);
a[1] = lx * pow(z, y);
a[2] = lx * y * z;
a[3] = a[2];
a[4] = ly * pow(x, z);
a[5] = ly * pow(z, x);
a[6] = ly * x * z;
a[7] = a[6];
a[8] = lz * pow(x, y);
a[9] = lz * pow(y, x);
a[10] = lz * x * y;
a[11] = a[10];
long double max = a[0];
int idx = 0;
for (int i = 1; i < 12; i++) {
if (a[i] > max) {
max = a[i];
idx = i;
}
}
cout << s[idx] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-8;
long double a[12];
char w[12][10] = {"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"};
bool isEqual(long double a, long double b) { return fabs(a - b) < eps; }
int cmp(long double a, long double b) {
if (isEqual(a, b)) return 0;
if (a < b) return -1;
return 1;
}
int main() {
long double x, 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[10] = a[11] = x * y * log(z);
int pos = 0;
for (int i = 1; i < 12; i++) {
if (cmp(a[i], a[pos]) > 0) pos = i;
}
printf("%s\n", w[pos]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
long double x, y, z, ans = -1 * (1e9);
string out[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"};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> x >> y >> z;
int pos = -1;
if (log(x) * pow(y, z) > ans) {
ans = log(x) * pow(y, z);
pos = 0;
}
if (log(x) * pow(z, y) > ans) {
ans = log(x) * pow(z, y);
pos = 1;
}
if (log(x) * y * z > ans) {
ans = log(x) * y * z;
pos = 2;
}
if (log(x) * z * y > ans) {
ans = log(x) * z * y;
pos = 2;
}
if (log(y) * pow(x, z) > ans) {
ans = log(y) * pow(x, z);
pos = 4;
}
if (log(y) * pow(z, x) > ans) {
ans = log(y) * pow(z, x);
pos = 5;
}
if (log(y) * x * z > ans) {
ans = log(y) * x * z;
pos = 6;
}
if (log(y) * x * z > ans) {
ans = log(y) * x * z;
pos = 6;
}
if (log(z) * pow(x, y) > ans) {
ans = log(z) * pow(x, y);
pos = 8;
}
if (log(z) * pow(y, x) > ans) {
ans = log(z) * pow(y, x);
pos = 9;
}
if (log(z) * x * y > ans) {
ans = log(y) * x * y;
pos = 10;
}
if (log(z) * x * y > ans) {
ans = log(y) * x * y;
pos = 10;
}
cout << out[pos] << endl;
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.