text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; set<string> S; int n, ans; char buf[1000010]; int main() { while (gets(buf)) { n = strlen(buf); if (buf[0] == '+') { S.insert(string(buf + 1, buf + n)); } else if (buf[0] == '-') { S.erase(string(buf + 1, buf + n)); } else { int p; for (p = 0; p < n && buf[p] != ':'; ++p) ; ans += (int)S.size() * (n - p - 1); } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; unordered_set<string> set; unsigned int bytes = 0; while (getline(cin, s)) { if (s[0] == '+') set.insert(s.substr(1, s.size())); else if (s[0] == '-') set.erase(s.substr(1, s.size())); else { unsigned int pos = s.find(':'); string message = s.substr(pos + 1, s.size()); bytes += (message.size() * set.size()); } } cout << bytes; }
#include <bits/stdc++.h> using namespace std; char buf[1000]; int main() { int res = 0; int ic = 0; while (gets(buf)) { if (buf[0] == '+') ic++; else if (buf[0] == '-') ic--; else { int x = 0; while (buf[x] != ':') x++; int len = 0; x++; while (buf[x]) { x++; len++; } res += len * ic; } } printf("%d\n", res); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int count = 0, ans = 0, spare = 0; while (true) { string s; getline(cin, s); if (s.empty()) { cout << ans; break; } if (s[0] == '+') count++; else if (s[0] == '-') count--; else { int start = s.find(':'); int length = s.length() - start - 1; ans += count * length; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int cnt = 0; int res = 0; while (getline(cin, s)) { if (s[0] == '+') ++cnt; else if (s[0] == '-') --cnt; else { int i = 0; while (s[i] != ':') i += 1; res += (s.length() - i - 1) * cnt; } } printf("%d", res); return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> T power(T a, T b) { T x; if (b == 0) x = 1; else x = a; for (size_t i = 1; i < b; i++) x *= a; return x; } long long int gcd(long long int a, long long int b) { return b == 0 ? a : gcd(b, a % b); } long long int n, m, a, b, c, ab, ba, x, y, z, avg, sum; int arr3[1000001], arr4[200001], arr5[100001]; bool f, f1, f2; string str, s1, s2, s3, s4; set<int> seto; double d, d1; long long int x1, x2, y11, y2; int mini = 1 << 30, maxi = 0; vector<int> v; stack<int> s; string arr[1001]; int main() { while (getline(cin, str)) { if (str[0] == '+') sum++; else if (str[0] == '-') sum--; else x += str.substr(str.find(':') + 1).size() * sum; } cout << x; }
#include <bits/stdc++.h> using namespace std; string a[1000]; vector<string> Q; int main() { int tol = 0, sum = 0; while (getline(cin, a[tol])) tol++; for (int i = 0; i < tol; i++) { string tmp = ""; if (a[i][0] == '+') { for (int j = 1; j < a[i].size(); j++) tmp += a[i][j]; Q.push_back(tmp); } else if (a[i][0] == '-') { for (int j = 1; j < a[i].size(); j++) tmp += a[i][j]; int l = Q.size(); for (int j = 0; j < l; j++) if (Q[j] == tmp) { Q.erase(Q.begin() + j); break; } } else { int ans = a[i].size(); int tol = 0; while (a[i][tol] != ':') { tol++; } tol++; sum += (ans - tol) * Q.size(); } } printf("%d\n", sum); }
#include <bits/stdc++.h> int main(void) { using namespace std; ios_base::sync_with_stdio(false); unordered_set<string> names; int traffic = 0; while (1) { string line; getline(cin, line); if (!cin) { cout << traffic; return 0; } if (line[0] == '+') { names.insert(line.substr(1, string::npos)); } else if (line[0] == '-') { names.erase(line.substr(1, string::npos)); } else { int k = line.find(":"); traffic += (line.size() - k - 1) * names.size(); } } }
#include <bits/stdc++.h> using namespace std; int main() { string a; int count = 0, sum = 0; while (getline(cin, a)) { if (a[0] == '+') count++; else if (a[0] == '-') count--; else sum = sum + a.substr(a.find(':') + 1).length() * count; } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int cnt, ans; string s; int main() { while (getline(cin, s)) { if (s[0] == '+') { cnt++; } else if (s[0] == '-') { cnt--; } else { int f = 0, k = s.size(); for (int i = 0; i < k; i++) { if (s[i] == ':') { f = i; break; } } ans += (k - f - 1) * cnt; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> int main() { int i, l = 0, p = 0, sum = 0, f = 0; char s; while (scanf("%c", &s) != EOF) { if (s == '\n') { f = 0; sum += p * l; l = 0; } else if (s == ':') { f = 1; } else if (f == 1) { l++; } else if (s == '+') { p++; f = 0; } else if (s == '-') { p--; f = 0; } } printf("%d", sum); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { set<string> member; string msg; int ans = 0; while (getline(cin, msg)) { if (msg[0] == '+') { msg.erase(msg.begin()); member.insert(msg); } else if (msg[0] == '-') { msg.erase(msg.begin()); member.erase(msg); } else { int len = msg.length(); int pos = msg.find(":"); ans += (member.size() * (len - pos - 1)); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int Count, Ans; int main() { int i; char s[200]; while (gets(s)) { if (s[0] == '+') ++Count; else if (s[0] == '-') --Count; else { for (i = 0; s[i] != ':'; i++) ; Ans += (strlen(s) - i - 1) * Count; } } printf("%d\n", Ans); return 0; }
#include <bits/stdc++.h> using namespace std; long long n, i, a[3], j, x, c, ans; string s; int main() { c = 0; ans = 0; while (getline(cin, s)) { switch (s[0]) { case '+': { c++; break; } case '-': { c--; break; } default: { ans += c * (s.length() - s.find(':') - 1); break; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool f() { int ans = 0, cnt = 0; string s; while (getline(cin, s)) { if (s[0] == '+') cnt++; else if (s[0] == '-') cnt--; else ans += cnt * (s.size() - s.find_first_of(':') - 1); } printf("%d", ans); return true; } int main() { f(); }
#include <bits/stdc++.h> using namespace std; string ss; set<string> st; int main() { ios::sync_with_stdio(false); long long ans = 0; while (getline(cin, ss)) { if (ss[0] == '-') st.erase(ss.substr(1)); else if (ss[0] == '+') st.insert(ss.substr(1)); else ans += (int)(st).size() * (int)(ss.substr(ss.find_first_of(':') + 1)).size(); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int cnt, res; string tmp; int main() { res = 0; cnt = 0; while (!cin.eof()) { getline(cin, tmp); if (tmp[0] == '+') ++cnt; else if (tmp[0] == '-') --cnt; else { res += string(tmp, tmp.find(':') + 1).size() * cnt; } } cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; int add = 0, traffic = 0; string a; int main() { while (getline(cin, a)) { if (a[0] == '+') add++; else if (a[0] == '-') add--; else { traffic += (add * (a.size() - a.find(':') - 1)); } } cout << traffic; }
#include <bits/stdc++.h> using namespace std; int an; long long int ans; int main() { string s; while (getline(cin, s)) { if (s[0] == '+') an++; if (s[0] == '-') an--; if (s[0] != '+' && s[0] != '-') { int goh = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == ':') { goh = s.size() - i - 1; continue; } } ans += (an * goh); } } cout << ans; }
#include <bits/stdc++.h> using namespace std; int a, b; string s; int main() { while (getline(cin, s)) if (s[0] == '+') a++; else if (s[0] == '-') a--; else b += a * (s.size() - s.find(':') - 1); cout << b << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char s[110]; int num = 0; int main() { num = 0; set<string> t; int ans = 0; while (gets(s)) { if (s[0] == '+') { string tmp = ""; int len = strlen(s); for (int i = 1; i < len; i++) tmp += s[i]; t.insert(tmp); num++; } else if (s[0] == '-') { string tmp = ""; int len = strlen(s); for (int i = 1; i < len; i++) tmp += s[i]; t.erase(tmp); num--; } else { int i = 0; for (i = 0; i < strlen(s); i++) if (s[i] == ':') break; ans += (strlen(s) - i - 1) * num; } } cout << ans << endl; return (0); }
#include <bits/stdc++.h> using namespace std; int main() { set<string> usrs; char buff[120]; int bits = 0; while (fgets(buff, 120, stdin) != NULL) { int i = 0; for (; buff[i] != '\n'; ++i) ; buff[i] = 0; if (buff[0] == '+') usrs.insert(string(buff + 1)); else if (buff[0] == '-') usrs.erase(string(buff + 1)); else { int it = 0; while (buff[it] != ':') ++it; buff[it] = '\0'; string u = string(buff); string tmp = string(buff + it + 1); if (usrs.find(u) != usrs.end()) bits += usrs.size() * tmp.size(); } } printf("%d\n", bits); }
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; string s; int member = 0, ans = 0, i; while (getline(cin, s)) { if (s[0] == '+') member++; else if (s[0] == '-') member--; else { ans += (member * (s.length() - s.find(':') - 1)); } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> char buff[102]; int numPeople = 0; int traffic = 0; int getTrafficSize(); int main(int argc, char *argv[]) { while (gets(buff)) { if (buff[0] == '+') ++numPeople; else if (buff[0] == '-') --numPeople; else traffic += getTrafficSize(); } printf("%d\n", traffic); return 0; } int getTrafficSize() { int trafficSize = 0; char *temp = buff; while (*temp++ != ':') ; while (*temp++ != '\0') ++trafficSize; return trafficSize * numPeople; }
#include <bits/stdc++.h> using namespace std; char str[1005]; int main() { int cnt = 0; int ans = 0; while (gets(str)) { if (str[0] == '+') cnt++; else if (str[0] == '-') cnt--; else { for (int i = 0; i < strlen(str); ++i) if (str[i] == ':') ans += (strlen(str) - i - 1) * cnt; } } printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; string s[101]; int main() { int i = 0, sum = 0, ans = 0; while (getline(cin, s[i])) { if (s[i][0] == '+') sum++; else if (s[i][0] == '-') sum--; else { int j = 0; int cnt = 0; while (1) { j++; if (s[i][j] == ':') break; } cnt = s[i].length() - j - 1; ans += cnt * sum; } i++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; int ans = 0; int k = 0; while (getline(cin, s)) { if (s[0] == '-') { k--; continue; } if (s[0] == '+') { k++; continue; } int L = int((s).size()); int it = 0; while (s[it] != ':') it++; ans += k * (L - it - 1); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100010; int ans, p; int main() { cin.tie(0); ios::sync_with_stdio(false); string str; while (getline(cin, str)) { if (str[0] == '+') p += 1; else if (str[0] == '-') p -= 1; else { int z = str.find(':'); ans += p * (str.size() - 1 - z); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int mxn = 1e4; int main() { char arr[mxn]; int num = 0, res = 0; while (cin.get(arr, mxn, '\n')) { ; cin.get(); if (arr[0] == '+') num++; else if (arr[0] == '-') num--; else { int i = 0; while (i < strlen(arr) && arr[i] != ':') i++; res += (strlen(arr) - i - 1) * num; } } cout << res; }
#include <bits/stdc++.h> using namespace std; int main(void) { int i, sum = 0; string str; size_t pos; vector<string> chatList; while (getline(cin, str)) { if (str.size() == 0) break; if (str[0] == '+') { string temp = str.substr(1); chatList.push_back(temp); } else if (str[0] == '-') { string temp = str.substr(1); chatList.erase(remove(chatList.begin(), chatList.end(), temp), chatList.end()); } else { if (str.find(":") != string::npos) { pos = str.find_first_of(":"); string temp = str.substr(pos); sum += (temp.size() - 1) * chatList.size(); } } } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int i = 0; int lidi = 0; int soucet = 0; while (cin) { getline(cin, s); if (s[0] == '+') lidi++; if (s[0] == '-') lidi--; int a = 0; while (a < s.length() && s[a] != ':') a++; if (a < s.length()) soucet += lidi * (s.length() - a - 1); i++; } cout << soucet << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long ma = -1e9, mi = 1e9; using namespace std; int const N = 1e5; int main() { string s, a; set<string> my; int x = 0, ans = 0; while (getline(cin, s)) { if (s[0] == '-') { s.erase(0, 1); my.erase(s); } else if (s[0] == '+') { s.erase(0, 1); my.insert(s); } else { string a = ""; char c = s[0]; for (int i = 1; i < s.size(); ++i) { if (s[i] == ':') break; a += s[i]; } int x = s.size() - (a.size() + 2); ans += (x * my.size()); } } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { long long l = 0; string str, msg; set<string> users; while (getline(cin, str)) { if (str[0] == '+') { str[0] = '@'; users.insert(str); } else if (str[0] == '-') { str[0] = '@'; users.erase(str); } else { string::size_type colon = str.find(":", 0); if (colon != string::npos) { l += (((long long)str.size()) - ((long long)colon) - 1LL) * ((long long)users.size()); } } } printf("%I64d\n", l); return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> string toStr(const T &x) { stringstream s; s << x; return s.str(); } template <class T> int toInt(const T &x) { stringstream s; s << x; int r; s >> r; return r; } int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0}; int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1}; int main() { string s; int cur = 0; int ans = 0; while (getline(cin, s)) { if (s[0] == '+') cur++; else if (s[0] == '-') cur--; else { stringstream ss; ss << s; string msj; while (getline(ss, msj, ':')) ; ans += msj.size() * cur; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; char a[1000]; int main() { int i, j, k, m, n; int num = 0, max = 0; while (gets(a) != NULL) { if (a[0] == '+') num++; else if (a[0] == '-') num--; else if (a[0] != '+' && a[0] != '-') { for (i = 0; i < strlen(a); i++) if (a[i] == ':') break; max += (strlen(a) - i - 1) * num; } } printf("%d\n", max); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int renshu = 0; int zijieshu = 0; string oper; while (getline(cin, oper, '\n')) { if (oper[0] == '+') { renshu++; } else if (oper[0] == '-') { renshu--; } else { int kal = oper.find(':', 0); zijieshu += (oper.size() - kal - 1) * renshu; } } cout << zijieshu << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int now = 0, sumall = 0; char c[105]; while (gets(c) != NULL) { if (c[0] == '+') now++; else { if (c[0] == '-') now--; else { int sum1 = 0, lo = strlen(c) - 1, i; for (i = 0; i <= lo; i++) { if (c[i] == ':') break; } for (; i <= lo; i++) { sum1++; } sumall += now * (sum1 - 1); } } } printf("%d", sumall); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0; int p = 0; string inp; while (getline(cin, inp)) { if (inp[0] == '+') { p++; } else if (inp[0] == '-') { p--; } else { int len = inp.size(); for (int i = 0; i < inp.size(); i++) { if (inp[i] == ':') { len = len - i - 1; break; } } ans = ans + p * len; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int i, a; string s; int main() { while (!cin.eof()) { getline(cin, s); if (s[0] == '+') i++; else if (s[0] == '-') i--; else a += i * (s.size() - s.find(":") - 1); } cout << a; }
#include <bits/stdc++.h> using namespace std; string s[10005]; int main() { int q = 0; int amount = 0; int ans = 0; while (getline(cin, s[q])) { if (s[q][0] == '+') { amount++; } else if (s[q][0] == '-') { amount--; } else { int i; int len = s[q].size(); for (i = 0; i < len; i++) { if (s[q][i] == ':') break; } ans += (len - i - 1) * amount; } q++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> char l[120], a[120], b[120]; int u, t; int main(void) { while (scanf("%[^\n]", l) > 0) { if (sscanf(l, "%[^:]:%[^\n]", a, b) == 2) t += u * strlen(b); else if (l[0] == '+') ++u; else if (l[0] == '-') --u; scanf("%*c"); } printf("%d", t); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { int l = 0, n = 0; string s; while (getline(cin, s)) { if (s[0] == '+') n++; else if (s[0] == '-') n--; else l += n * (s.size() - s.find(':') - 1); } cout << l; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t = 1; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int cnt = 0, len = 0, ans = 0, i; char xx[3][111]; while (gets(xx[0]) != NULL) { if (xx[0][0] == '+') cnt++; else if (xx[0][0] == '-') cnt--; else { for (i = 0; xx[0][i]; i++) if (xx[0][i] == ':') break; ans = ans + (strlen(xx[0]) - i - 1) * cnt; } } printf("%d\n", ans); }
#include <bits/stdc++.h> using namespace std; char s[1005]; int main() { int m, ans, f; m = 0; ans = 0; while (fgets(s, sizeof(s), stdin) != NULL) { if (s[0] == '+') m++; if (s[0] == '-') m--; if (strchr(s, ':') != NULL) { f = 0; for (int i = 0; i < strlen(s) - 1; i++) { if (f == 1) ans += m; if (s[i] == ':') f = 1; } } } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; char s[1005]; int main() { int m, ans, f; m = 0; ans = 0; while (fgets(s, sizeof(s), stdin) != NULL) { if (s[0] == '+') m++; if (s[0] == '-') m--; if (strchr(s, ':') != NULL) { f = 0; for (int i = 0; i < strlen(s) - 1; i++) { if (s[i] == ':') { f = i + 1; break; } } ans += m * (strlen(s) - 1 - f); } } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char a[100]; int sum = 0; int ans = 0; while (gets(a)) { int len = strlen(a); if (a[0] == '+') sum++; else if (a[0] == '-') sum--; else { int p = 0; for (int i = 0; i < len; i++) if (a[i] == ':') p = i; ans += (len - p - 1) * sum; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string x; int count = 0; int total = 0; while (getline(cin, x)) { if (x[0] == '+') count++; else if (x[0] == '-') count--; else if (x[0] != '+' && x[0] != '-') { int l = (x.length() - 1) - x.find(':'); total += l * count; } } cout << total; return 0; }
#include <bits/stdc++.h> using namespace std; char s[1005]; int main() { int ret = 0; int p = 0; while (gets(s)) { if (s[0] == '+') p++; else if (s[0] == '-') p--; else { int cnt = 0; while (s[cnt] != ':') cnt++; ret += (strlen(s) - cnt - 1) * p; } } printf("%d\n", ret); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int flow = 0, now = 0; string s; while (getline(cin, s)) { if (s[0] == '+') now++; else if (s[0] == '-') now--; else { for (int i = 0; i < s.size(); i++) { if (s[i] == ':') { flow += (s.size() - i - 1) * now; break; } } } } cout << flow; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int len = 0, slen = 0, pos; while (getline(cin, s) && s.length()) { if (s.at(0) == '+') len++; else if (s.at(0) == '-') len--; else { pos = s.find(":"); slen += (s.substr(pos + 1).size()) * len; } } cout << slen; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int counta = 0; int people = 0; string s; while (getline(cin, s)) { if (s[0] == '+') people++; else if (s[0] == '-') people--; else { int pos = s.find(':'); int l = s.length() - pos - 1; counta = counta + people * l; } } cout << counta; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char temp[101]; int members = 0; int bytes = 0; while (gets(temp)) { if (temp[0] == '+') { members++; } else if (temp[0] == '-') { members--; } else { int i = 0; while (temp[i] != ':') { i++; } i++; int number = 0; while (temp[i] != '\0') { number++; i++; } bytes += number * members; } } cout << bytes << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char c[101]; int count = 0; int sum = 0; while (cin.getline(c, 101)) { if (c[0] == '+') { count++; continue; } if (c[0] == '-') { count--; continue; } int x = 0; for (; c[x] != ':'; x++) { } sum += (strlen(c) - (x + 1)) * count; } cout << sum; }
#include <bits/stdc++.h> using namespace std; char s[110]; int main() { int i, j, l, c = 0, ans = 0; while (gets(s)) { if (s[0] == '+') c++; else if (s[0] == '-') c--; else { int tmp = 0; l = strlen(s); for (i = 0; i < l; i++) if (s[i] == ':') break; tmp = l - i - 1; ans += tmp * c; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; 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]; } using CurrentSolver = Solver621D; int main() { ios::sync_with_stdio(false); CurrentSolver().run(); return 0; }
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979; const double eps = 1e-6; const long long _INF = 1e18; const int INF = 1e9; const int maxn = 1000010; const int maxm = 1000010; double x, y, z; char ans[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"}; double a[12]; int main() { while (~scanf("%lf %lf %lf", &x, &y, &z)) { if (x > 1 || y > 1 || z > 1) { if (x > 1) { a[0] = z * log(y) + log(log(x)); a[1] = y * log(z) + log(log(x)); a[2] = log(y) + log(z) + log(log(x)); a[3] = -_INF; } else a[0] = a[1] = a[2] = a[3] = -_INF; if (y > 1) { a[4] = z * log(x) + log(log(y)); a[5] = x * log(z) + log(log(y)); a[6] = log(x) + log(z) + log(log(y)); a[7] = -_INF; } else a[4] = a[5] = a[6] = a[7] = -_INF; if (z > 1) { a[8] = y * log(x) + log(log(z)); a[9] = x * log(y) + log(log(z)); a[10] = log(x) + log(y) + log(log(z)); a[11] = -_INF; } else a[8] = a[9] = a[10] = a[11] = -_INF; int idx = 0; double x = a[0]; for (int i = 1; i < 12; ++i) if (a[i] > x) { idx = i; x = a[i]; } puts(ans[idx]); } else { a[0] = z * log(y) + log(log(1.0 / x)); a[1] = y * log(z) + log(log(1.0 / x)); a[2] = log(y) + log(z) + log(log(1.0 / x)); a[3] = _INF; a[4] = z * log(x) + log(log(1.0 / y)); a[5] = x * log(z) + log(log(1.0 / y)); a[6] = log(x) + log(z) + log(log(1.0 / y)); a[7] = _INF; a[8] = y * log(x) + log(log(1.0 / z)); a[9] = x * log(y) + log(log(1.0 / z)); a[10] = log(x) + log(y) + log(log(1.0 / z)); a[11] = _INF; int idx = 0; double x = a[0]; for (int i = 1; i < 12; ++i) if (a[i] < x) { idx = i; x = a[i]; } puts(ans[idx]); } } return 0; }
#include <bits/stdc++.h> using namespace std; inline long double f(long double a, long double b) { return a * pow(2, b); } int main() { ios::sync_with_stdio(0); long double x, y, z; cin >> x >> y >> z; string ans = "x^y^z"; long double mn = f(log2(x), f(log2(y), log2(z))); if (mn < f(log2(x), f(log2(z), log2(y)))) { mn = f(log2(x), f(log2(z), log2(y))); ans = "x^z^y"; } if (mn < f(f(log2(x), log2(y)), log2(z))) { mn = f(f(log2(x), log2(y)), log2(z)); ans = "(x^y)^z"; } if (mn < f(log2(y), f(log2(x), log2(z)))) { mn = f(log2(y), f(log2(x), log2(z))); ans = "y^x^z"; } if (mn < f(log2(y), f(log2(z), log2(x)))) { mn = f(log2(y), f(log2(z), log2(x))); ans = "y^z^x"; } if (mn < f(f(log2(y), log2(x)), log2(z))) { mn = f(f(log2(y), log2(x)), log2(z)); ans = "(y^x)^z"; } if (mn < f(log2(z), f(log2(x), log2(y)))) { mn = f(log2(z), f(log2(x), log2(y))); ans = "z^x^y"; } if (mn < f(log2(z), f(log2(y), log2(x)))) { mn = f(log2(z), f(log2(y), log2(x))); ans = "z^y^x"; } if (mn < f(f(log2(z), log2(x)), log2(y))) { mn = f(f(log2(z), log2(x)), log2(y)); ans = "(z^x)^y"; } cout << ans; }
#include <bits/stdc++.h> using namespace std; bool cmp(pair<long double, int> a, pair<long double, int> b) { if (fabs(a.first - b.first) < (long double)1e-9) return a.second > b.second; return a.first < b.first; } long double nlog(long double x) { return log(x) / log((long double)0.5); } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); map<int, string> ans; ans[1] = "x^y^z"; ans[2] = "x^z^y"; ans[3] = "(x^y)^z"; ans[5] = "y^x^z"; ans[6] = "y^z^x"; ans[7] = "(y^x)^z"; ans[9] = "z^x^y"; ans[10] = "z^y^x"; ans[11] = "(z^x)^y"; long double x, y, z; cin >> x >> y >> z; vector<pair<long double, int>> vx = {make_pair(log(y) + log(z), 3), make_pair(y * log(z), 2), make_pair(z * log(y), 1)}; sort(vx.begin(), vx.end(), cmp); if (x < (long double)1) reverse(vx.begin(), vx.end()); vector<pair<long double, int>> vy = {make_pair(log(x) + log(z), 7), make_pair(x * log(z), 6), make_pair(z * log(x), 5)}; sort(vy.begin(), vy.end(), cmp); if (y < (long double)1) reverse(vy.begin(), vy.end()); vector<pair<long double, int>> vz = {make_pair(log(x) + log(y), 11), make_pair(x * log(y), 10), make_pair(y * log(x), 9)}; sort(vz.begin(), vz.end(), cmp); if (z < (long double)1) reverse(vz.begin(), vz.end()); vector<pair<long double, int>> sup_1, inf_1, one; if (x > (long double)1) sup_1.push_back(vx.back()), sup_1.back().first += log(log(x)); if (x < (long double)1) inf_1.push_back(vx.back()), inf_1.back().first = (inf_1.back().first) / log((long double)0.5) + nlog(nlog(x)); if (x == (long double)1) one.push_back(vx.back()), one.back().first = 1; if (y > (long double)1) sup_1.push_back(vy.back()), sup_1.back().first += log(log(y)); if (y < (long double)1) inf_1.push_back(vy.back()), inf_1.back().first = (inf_1.back().first) / log((long double)0.5) + nlog(nlog(y)); if (y == (long double)1) one.push_back(vy.back()), one.back().first = 1; if (z > (long double)1) sup_1.push_back(vz.back()), sup_1.back().first += log(log(z)); if (z < (long double)1) inf_1.push_back(vz.back()), inf_1.back().first = (inf_1.back().first) / log((long double)0.5) + nlog(nlog(z)); if (z == (long double)1) one.push_back(vz.back()), one.back().first = 1; sort(sup_1.begin(), sup_1.end(), cmp); sort(inf_1.begin(), inf_1.end(), cmp); sort(one.begin(), one.end(), cmp); if (!sup_1.empty()) cout << ans[sup_1.back().second] << '\n'; else if (!one.empty()) cout << ans[one.back().second] << '\n'; else cout << ans[inf_1.back().second] << '\n'; return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const long long LLINF = 0x3f3f3f3f3f3f3f3f; const int maxn = 1e2 + 10; const int maxm = 1e5 + 10; 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 F(long double x, long double y, long double z) { long double ans = pow(y, z) * log(x); return ans; } long double G(long double x, long double y, long double z) { long double ans = y * z * log(x); return ans; } int main(int argc, char const *argv[]) { long double x, y, z; cin >> x >> y >> z; long double val = -1e300; int ans = 0; if (F(x, y, z) > val) val = F(x, y, z), ans = 0; if (F(x, z, y) > val) val = F(x, z, y), ans = 1; if (G(x, y, z) > val) val = G(x, y, z), ans = 2; if (G(x, z, y) > val) val = G(x, z, y), ans = 3; if (F(y, x, z) > val) val = F(y, x, z), ans = 4; if (F(y, z, x) > val) val = F(y, z, x), ans = 5; if (G(y, x, z) > val) val = G(y, x, z), ans = 6; if (G(y, z, x) > val) val = G(y, z, x), ans = 7; if (F(z, x, y) > val) val = F(z, x, y), ans = 8; if (F(z, y, x) > val) val = F(z, y, x), ans = 9; if (G(z, x, y) > val) val = G(z, x, y), ans = 10; if (G(z, y, x) > val) val = G(z, y, x), ans = 11; cout << s[ans] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; long double x, y, z; string expre[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"}; long double val[13]; long double calc1(long double x, long double y, long double z) { return pow(y, z) * log(x); } long double calc2(long double x, long double y, long double z) { return y * z * log(x); } int findMax() { long double Max = val[1]; int pos = 1; for (int i = 2; i <= 12; ++i) { if ((val[i] - Max) > eps) { Max = val[i]; pos = i; } } return pos; } int main() { while (cin >> x >> y >> z) { val[1] = calc1(x, y, z); val[2] = calc1(x, z, y); val[3] = calc2(x, y, z); val[4] = calc2(x, z, y); val[5] = calc1(y, x, z); val[6] = calc1(y, z, x); val[7] = calc2(y, x, z); val[8] = calc2(y, z, x); val[9] = calc1(z, x, y); val[10] = calc1(z, y, x); val[11] = calc2(z, x, y); val[12] = calc2(z, y, x); cout << expre[findMax()] << endl; } }
#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; } 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 && abs(a[i] - ans) > eps) { 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; bool crit(pair<long double, int> a, pair<long double, int> b) { if (abs(a.first - b.first) < 0.000000001) return a.second < b.second; return a.first > b.first; } long double x, y, z, a; vector<pair<long double, int>> v; int main() { cin.sync_with_stdio(false); cout.sync_with_stdio(false); cin >> x >> y >> z; v.push_back(make_pair(pow(y, z) * log10(x), 1)); v.push_back(make_pair(pow(z, y) * log10(x), 2)); v.push_back(make_pair(z * y * (log10(x)), 3)); v.push_back(make_pair(pow(x, z) * log10(y), 4)); v.push_back(make_pair(pow(z, x) * log10(y), 5)); v.push_back(make_pair(z * x * (log10(y)), 6)); v.push_back(make_pair(pow(x, y) * log10(z), 7)); v.push_back(make_pair(pow(y, x) * log10(z), 8)); v.push_back(make_pair(x * y * (log10(z)), 9)); sort(v.begin(), v.end(), crit); switch (v[0].second) { case 1: { cout << "x^y^z"; break; } case 2: { cout << "x^z^y"; break; } case 3: { cout << "(x^y)^z"; break; } case 4: { cout << "y^x^z"; break; } case 5: { cout << "y^z^x"; break; } case 6: { cout << "(y^x)^z"; break; } case 7: { cout << "z^x^y"; break; } case 8: { cout << "z^y^x"; break; } case 9: { cout << "(z^x)^y"; break; } } return 0; }
#include <bits/stdc++.h> using namespace std; const int max_n = 22, inf = 1111111111; string ans[max_n]; long double x, y, z, a[max_n]; int main() { cin >> x >> y >> z; ans[0] = "x^y^z"; ans[1] = "x^z^y"; ans[2] = "(x^y)^z"; ans[3] = "y^x^z"; ans[4] = "y^z^x"; ans[5] = "(y^x)^z"; ans[6] = "z^x^y"; ans[7] = "z^y^x"; ans[8] = "(z^x)^y"; a[0] = log(x) * pow(y, z); a[1] = log(x) * pow(z, y); a[2] = log(x) * y * z; a[3] = log(y) * pow(x, z); a[4] = log(y) * pow(z, x); a[5] = log(y) * x * z; a[6] = log(z) * pow(x, y); a[7] = log(z) * pow(y, x); a[8] = log(z) * x * y; int poz = 0; for (int i = 1; i < 9; ++i) { if (a[i] > a[poz]) { poz = i; } } cout << ans[poz] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-6; long double x, y, z, ans; int p, indd; string s[20]; bool cmp(long double a, long double b) { if (b + eps < a) return 1; return 0; } void val(long double a, long double b, long double c) { indd++; if (indd == 1 || cmp(pow(b, c) * log(a), ans)) { ans = pow(b, c) * log(a); p = indd; } } int main() { cin >> x >> y >> z; val(x, y, z); s[1] = "x^y^z"; val(x, z, y); s[2] = "x^z^y"; val(x, y * z, 1); s[3] = "(x^y)^z"; val(x, z * y, 1); s[4] = "(x^z)^y"; val(y, x, z); s[5] = "y^x^z"; val(y, z, x); s[6] = "y^z^x"; val(y, x * z, 1); s[7] = "(y^x)^z"; val(y, z * x, 1); s[8] = "(y^z)^x"; val(z, x, y); s[9] = "z^x^y"; val(z, y, x); s[10] = "z^y^x"; val(z, x * y, 1); s[11] = "(z^x)^y"; val(z, y * x, 1); s[12] = "(z^y)^x"; cout << s[p]; return 0; }
#include <bits/stdc++.h> using namespace std; long double A[9]; int main() { long double x, y, z; cin >> x >> y >> z; long double num[3]; num[0] = x, num[1] = y, num[2] = z; sort(num, num + 3); if (num[1] <= 1.0) { A[0] = powl(x, powl(y, z)); A[1] = powl(x, powl(z, y)); A[2] = powl(x, y * z); A[3] = powl(y, powl(x, z)); A[4] = powl(y, powl(z, x)); A[5] = powl(y, x * z); A[6] = powl(z, powl(x, y)); A[7] = powl(z, powl(y, x)); A[8] = powl(z, x * y); } else { if (x <= 1.0) { A[0] = A[1] = A[2] = -1e9; } else { y <= 1.0 ? A[0] = -1e9 : A[0] = z * logl(y) + logl(logl(x)); z <= 1.0 ? A[1] = -1e9 : A[1] = y * logl(z) + logl(logl(x)); z* y <= 1.0 ? A[2] = -1e9 : A[2] = logl(z * y) + logl(logl(x)); } if (y <= 1.0) { A[3] = A[4] = A[5] = -1e9; } else { x <= 1.0 ? A[3] = -1e9 : A[3] = z * logl(x) + logl(logl(y)); z <= 1.0 ? A[4] = -1e9 : A[4] = x * logl(z) + logl(logl(y)); x* z <= 1.0 ? A[5] = -1e9 : A[5] = logl(x * z) + logl(logl(y)); } if (z <= 1.0) { A[6] = A[7] = A[8] = -1e9; } else { x <= 1.0 ? A[6] = -1e9 : A[6] = y * logl(x) + logl(logl(z)); y <= 1.0 ? A[7] = -1e9 : A[7] = x * logl(y) + logl(logl(z)); x* y <= 1.0 ? A[8] = -1e9 : A[8] = logl(x * y) + logl(logl(z)); } } auto it = max_element(A, A + 9); if (it - A == 0) { printf("%c^%c^%c\n", 'x', 'y', 'z'); } else if (it - A == 1) { printf("%c^%c^%c\n", 'x', 'z', 'y'); } else if (it - A == 2) { printf("(%c^%c)^%c\n", 'x', 'y', 'z'); } else if (it - A == 3) { printf("%c^%c^%c\n", 'y', 'x', 'z'); } else if (it - A == 4) { printf("%c^%c^%c\n", 'y', 'z', 'x'); } else if (it - A == 5) { printf("(%c^%c)^%c\n", 'y', 'x', 'z'); } else if (it - A == 6) { printf("%c^%c^%c\n", 'z', 'x', 'y'); } else if (it - A == 7) { printf("%c^%c^%c\n", 'z', 'y', 'x'); } else { printf("(%c^%c)^%c\n", 'z', 'x', 'y'); } return 0; }
#include <bits/stdc++.h> using namespace std; 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]; } using CurrentSolver = Solver621D; int main() { ios::sync_with_stdio(false); CurrentSolver().run(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i; long double x, y, z; cin >> x >> y >> z; long double arr[12]; arr[0] = pow(y, z) * log(x); arr[1] = pow(z, y) * log(x); arr[2] = (y * z) * log(x); arr[3] = arr[2]; arr[4] = pow(x, z) * log(y); arr[5] = pow(z, x) * log(y); arr[6] = (x * z) * log(y); arr[7] = arr[6]; arr[8] = pow(x, y) * log(z); arr[9] = pow(y, x) * log(z); arr[10] = (x * y) * log(z); arr[11] = arr[10]; long double m = arr[0]; int p = 0; for (i = 0; i < 12; i++) if (arr[i] > m) { m = arr[i]; p = i; } if (p == 0) cout << "x^y^z" << endl; else if (p == 1) cout << "x^z^y" << endl; else if (p == 2) cout << "(x^y)^z" << endl; else if (p == 3) cout << "(x^z)^y" << endl; else if (p == 4) cout << "y^x^z" << endl; else if (p == 5) cout << "y^z^x" << endl; else if (p == 6) cout << "(y^x)^z" << endl; else if (p == 7) cout << "(y^z)^x" << endl; else if (p == 8) cout << "z^x^y" << endl; else if (p == 9) cout << "z^y^x" << endl; else if (p == 10) cout << "(z^x)^y" << endl; else cout << "(z^y)^x" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long double ar[13]; long double x, y, z; const string at[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"}; cin >> x >> y >> z; ar[0] = pow(y, z) * log(x); ar[1] = pow(z, y) * log(x); ar[2] = ar[3] = y * z * log(x); ar[4] = pow(x, z) * log(y); ar[5] = pow(z, x) * log(y); ar[6] = ar[7] = z * x * log(y); ar[8] = pow(x, y) * log(z); ar[9] = pow(y, x) * log(z); ar[10] = ar[11] = x * y * log(z); long double max = ar[0]; int k = 0; for (int i = 1; i < 12; i++) { if (ar[i] > max) { max = ar[i]; k = i; } } cout << at[k]; return 0; }
#include <bits/stdc++.h> using namespace std; pair<pair<bool, long double>, string> a[13]; bool comp(pair<pair<bool, long double>, string> a, pair<pair<bool, long double>, string> b) { auto t1 = a.first, t2 = b.first; if (t1.second < -10000 && t2.second < -10000) return false; if (t1.first != t2.first) return t1.first; if (abs(t1.second - t2.second) <= 1e-6) return false; return (t1.second < t2.second) ^ t1.first; } int main() { long double x, y, z; cin >> x >> y >> z; a[1] = {{x < 1, z * log10(y) + (x < 1 ? log10(-log10(x)) : log10(log10(x)))}, "x^y^z"}; a[2] = {{x < 1, y * log10(z) + (x < 1 ? log10(-log10(x)) : log10(log10(x)))}, "x^z^y"}; a[3] = {{x < 1, log10(y * z) + (x < 1 ? log10(-log10(x)) : log10(log10(x)))}, "(x^y)^z"}; a[4] = {{x < 1, log10(y * z) + (x < 1 ? log10(-log10(x)) : log10(log10(x)))}, "(x^z)^y"}; a[5] = {{y < 1, z * log10(x) + (y < 1 ? log10(-log10(y)) : log10(log10(y)))}, "y^x^z"}; a[6] = {{y < 1, x * log10(z) + (y < 1 ? log10(-log10(y)) : log10(log10(y)))}, "y^z^x"}; a[7] = {{y < 1, log10(z * x) + (y < 1 ? log10(-log10(y)) : log10(log10(y)))}, "(y^x)^z"}; a[8] = {{y < 1, log10(z * x) + (y < 1 ? log10(-log10(y)) : log10(log10(y)))}, "(y^z)^x"}; a[9] = {{z < 1, y * log10(x) + (z < 1 ? log10(-log10(z)) : log10(log10(z)))}, "z^x^y"}; a[10] = {{z < 1, x * log10(y) + (z < 1 ? log10(-log10(z)) : log10(log10(z)))}, "z^y^x"}; a[11] = {{z < 1, log10(y * x) + (z < 1 ? log10(-log10(z)) : log10(log10(z)))}, "(z^x)^y"}; a[12] = {{z < 1, log10(y * x) + (z < 1 ? log10(-log10(z)) : log10(log10(z)))}, "(z^y)^x"}; int ind = 1; for (int i = 2; i <= 12; i++) ind = (comp(a[ind], a[i]) ? i : ind); cout << a[ind].second << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool operator>(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); } } complex<long double> eval(string expr, vector<complex<long double> > xyz) { if (expr.at(0) == '(') { complex<long double> x = xyz[(int)expr.at(1) - 'x'], y = xyz[(int)expr.at(3) - 'x'], z = xyz[(int)expr.at(6) - 'x']; return log(log(x)) + log(y * z); } else { complex<long double> x = xyz[(int)expr.at(0) - 'x'], y = xyz[(int)expr.at(2) - 'x'], z = xyz[(int)expr.at(4) - 'x']; return log(log(x)) + log(y) * z; } } int main() { long double ax, ay, az; cin >> ax >> ay >> az; vector<complex<long double> > xyz = {complex<long double>(ax, 0), complex<long double>(ay, 0), complex<long double>(az, 0)}; complex<long double> cmax(3, 3); string exprs[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"}; string ans = ""; for (int i = 0; i < 9; i++) { if (eval(exprs[i], xyz) > cmax) { cmax = eval(exprs[i], xyz); ans = exprs[i]; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10, MAXM = 1e6 + 10; const int INF = INT_MAX, SINF = 0x3f3f3f3f; const long long llINF = LLONG_MAX; const int MOD = 1e9 + 7, mod = 998244353; const int inv2 = 5e8 + 4; long double x, y, z; long double a[MAXN]; string s[MAXN]; int main() { cin >> x >> y >> z; a[1] = powl(y, z) * log(x); a[2] = powl(z, y) * log(x); a[3] = z * y * log(x); a[4] = z * y * log(x); a[5] = powl(x, z) * log(y); a[6] = powl(z, x) * log(y); a[7] = z * x * log(y); a[8] = z * x * log(y); a[9] = powl(x, y) * log(z); a[10] = powl(y, x) * log(z); a[11] = x * y * log(z); a[12] = x * y * log(z); int cnt = max_element(a + 1, a + 13) - a; 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"; cout << s[cnt]; return 0; }
#include <bits/stdc++.h> using namespace std; long double x, y, z; long double a1[20], a2[20], a3[20]; string c[20]; inline long double f(long double x) { return (long double)log((long double)x); } inline long double f1(long double x, long double y) { return (long double)pow((long double)x, (long double)y); } struct comp { int id; long double x1, x2, x3; inline friend bool operator<(comp a, comp b) { if (x <= 1.0 || y <= 1.0 || z <= 1.0) return a.x2 > b.x2; else return a.x1 > b.x1; } } b[20]; int main() { cin >> x >> y >> z; long double lx = f(x), ly = f(y), lz = f(z); long double llx = f(lx), lly = f(ly), llz = f(lz); long double xy = f1(x, y), xz = f1(x, z), yx = f1(y, x), yz = f1(y, z), zx = f1(z, x), zy = f1(z, y); a1[1] = llx + ly * z; a1[2] = llx + lz * y; a1[3] = llx + ly + lz; a1[4] = lly + lx * z; a1[5] = lly + lz * x; a1[6] = lly + lx + lz; a1[7] = llz + lx * y; a1[8] = llz + ly * x; a1[9] = llz + lx + ly; a2[1] = yz * lx; a2[2] = zy * lx; a2[3] = z * y * lx; a2[4] = xz * ly; a2[5] = zx * ly; a2[6] = z * x * ly; a2[7] = xy * lz; a2[8] = yx * lz; a2[9] = x * y * lz; c[1] = "x^y^z"; c[2] = "x^z^y"; c[3] = "(x^y)^z"; c[4] = "y^x^z"; c[5] = "y^z^x"; c[6] = "(y^x)^z"; c[7] = "z^x^y"; c[8] = "z^y^x"; c[9] = "(z^x)^y"; for (int i = 1; i <= 9; i++) { b[i].x1 = a1[i]; b[i].x2 = a2[i]; b[i].id = i; } sort(b + 1, b + 10); cout << c[b[1].id] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long double a[12]; string ret[12]; double c; double cl(double t) { return log(t) / log(c); } double dl(double x) { return cl(cl(x)); } string f(char a, char b, char c) { string r; r += a; return r + '^' + b + '^' + c; } string s(char a, char b, char c) { string r; r += '('; return r + a + '^' + b + ')' + '^' + c; } int main() { int i; double x, y, z; cin >> x >> y >> z; c = min(2.0, x), c = min(min(y, z), c); if (c >= 1.0) c = 2; a[0] = logl(x) * powl(y, z); a[1] = logl(x) * powl(z, y); a[2] = y * z * logl(x); a[3] = logl(y) * powl(x, z); a[4] = logl(y) * powl(z, x); a[5] = logl(y) * x * z; a[6] = logl(z) * powl(x, y); a[7] = logl(z) * powl(y, x); a[8] = logl(z) * x * y; int ind = 0; for (i = 0; i < 9; ++i) if (a[ind] < a[i]) ind = i; char a = 'x', b = 'y', c = 'z'; ret[0] = f(a, b, c); ret[1] = f(a, c, b), ret[2] = s(a, b, c); ret[3] = f(b, a, c), ret[4] = f(b, c, a), ret[5] = s(b, a, c); ret[6] = f(c, a, b), ret[7] = f(c, b, a), ret[8] = s(c, a, b); cout << ret[ind] << endl; }
#include <bits/stdc++.h> using namespace std; const double esp = 1e-7; const int maxn = 1e5 + 50; char s[15][20] = {"", "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[15], x, y, z, ma = -1; cin >> x >> y >> z; a[1] = pow(y, z) * log(x); a[2] = pow(z, y) * log(x); a[3] = y * z * log(x); a[4] = z * y * log(x); a[5] = pow(x, z) * log(y); a[6] = pow(z, x) * log(y); a[7] = x * z * log(y); a[8] = z * x * log(y); a[9] = pow(x, y) * log(z); a[10] = pow(y, x) * log(z); a[11] = x * y * log(z); a[12] = y * x * log(z); int id = 0; for (int i = 1; i <= 12; i++) { if (ma < a[i]) { ma = a[i]; id = i; } } printf("%s\n", s[id]); }
#include <bits/stdc++.h> using namespace std; int main() { long double x, y, z; long double arr[15]; string s[15]; 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"; while (cin >> x >> y >> z) { arr[1] = log(x) * pow(y, z); arr[2] = log(x) * pow(z, y); arr[3] = z * y * log(x); arr[4] = arr[3]; arr[5] = log(y) * pow(x, z); arr[6] = log(y) * pow(z, x); arr[7] = z * x * log(y); arr[8] = arr[7]; arr[9] = log(z) * pow(x, y); arr[10] = log(z) * pow(y, x); arr[11] = x * y * log(z); arr[12] = arr[11]; long double zd = -1e16; int shu = 0; for (int i = 1; i <= 12; i++) { if (arr[i] > zd) { zd = arr[i]; shu = i; } } cout << s[shu] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char s[13][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]; long double x, y, z; 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] = x * y * log(z); a[12] = x * y * log(z); long double ma = -1000000; int pos = 0; for (int i = 1; i <= 12; i++) { if (a[i] > ma) { ma = a[i]; pos = i; } } cout << s[pos] << endl; }
#include <bits/stdc++.h> using namespace std; long double v[3]; long double cont(long double x, long double y, long double z, bool c) { if (c) return z * log(pow(x, y)); return pow(y, z) * log(x); } void calc(bool &com, int &head, vector<int> &tail, long double &maxi, bool parenthesis, int k, vector<int> &resp) { long double temp = cont(v[k], v[tail[0]], v[tail[1]], parenthesis); if (maxi + 1e-14 < temp) { resp = tail; head = k; maxi = temp; com = parenthesis; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); char op[3] = {'x', 'y', 'z'}; vector<vector<int> > perm(3); for (int i = 0; i < 3; i++) cin >> v[i]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) if (i != j) perm[i].push_back(j); vector<int> resp = perm[0]; bool com = false; long double maxi = cont(v[0], v[1], v[2], false); int head = 0; for (int k = 0; k < perm.size(); k++) { vector<int> temp = perm[k]; do { calc(com, head, temp, maxi, false, k, resp); } while (next_permutation(temp.begin(), temp.end())); temp = perm[k]; do { calc(com, head, temp, maxi, true, k, resp); } while (next_permutation(temp.begin(), temp.end())); } if (com) cout << "(" << op[head] << "^" << op[resp[0]] << ")^" << op[resp[1]] << "\n"; else cout << op[head] << "^" << op[resp[0]] << "^" << op[resp[1]] << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int init() { ios_base::sync_with_stdio(0); srand(time(NULL)); return 0; } int initializer = init(); template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template <typename T> istream &operator>>(istream &is, vector<T> &p) { for (int i = 0; i < p.size(); i++) is >> p[i]; return is; } class inputer { private: istream *istr; public: inputer(istream &is) : istr(&is) {} template <typename T> void get(T &n) { (*istr) >> n; } template <typename T, typename... Args> void get(T &n, Args &...args) { get(n); get(args...); } template <typename... Args> void getln(Args &...args) { get(args...); ln(); } template <typename T> operator T() { T n; get(n); return n; } void ln() { string s; getline(cin, s); } template <typename T> void getv(vector<T> &v, int size) { v.resize(size); (*istr) >> v; } }; string delim = " "; template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << delim << p.second; return os; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &p) { for (int i = 0; i < p.size(); i++) { if (i != 0) os << delim; os << p[i]; } return os; } class outputer { private: ostream *ostr; public: outputer(ostream &os) : ostr(&os) {} template <typename T> void put(const T &n) { (*ostr) << n; } template <typename T, typename... Args> void put(const T &n, const Args &...args) { put(n); put(args...); } template <typename... Args> void putln(const Args &...args) { put(args...); ln(); } template <typename T> outputer &operator=(const T &n) { put(n); return *this; } void ln() { (*ostr) << "\n"; } template <typename T> void putv(vector<T> v, int size) { for (int i = 0; i < size; i++) { if (i != 0) (*ostr) << delim; (*ostr) << v[i]; } } }; inputer in(cin); outputer out(cout); bool will_it_be_AC() { return true; ; } int get_my_rating() { return 2016; } bool prime(long long n) { for (long long i = 2; i * i <= n; i++) if (n % i == 0) return false; return true; } vector<long long> divs(long long n) { vector<long long> v; long long i = 2; while (i * i <= n) if (n % i == 0) { n /= i; v.push_back(i); } else i++; v.push_back(n); return v; } long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long extgcd(long long a, long long b, long long &x, long long &y) { if (a == 0) { x = 0; y = 1; return b; } long long x1, y1, d = extgcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return d; } template <typename T> class fenwick { private: vector<T> t; int n; public: fenwick(int nn) { init(nn); } void init(int nn) { n = nn; t.assign(n, 0); } T sum(int r) { T result = 0; for (; r >= 0; r = (r & (r + 1)) - 1) result += t[r]; return result; } void inc(int i, T delta) { for (; i < n; i = (i | (i + 1))) t[i] += delta; } T sum(int l, int r) { return sum(r) - sum(l - 1); } T get(int i) { return sum(i, i); } void put(int i, T v) { inc(i, v - sum(i, i)); } int size() { return n; } }; bool cmp(pair<long double, int> a, pair<long double, int> b) { if (abs(a.first - b.first) <= 1e-7) return a.second < b.second; else return a.first > b.first; } const string a[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() { long double x = in, y = in, z = in, lgx = log(x), lgy = log(y), lgz = log(z); vector<pair<long double, int> > v; v.push_back({lgx * pow(y, z), 0}); v.push_back({lgx * pow(z, y), 1}); v.push_back({lgx * y * z, 2}); v.push_back({lgx * z * y, 3}); v.push_back({lgy * pow(x, z), 4}); v.push_back({lgy * pow(z, x), 5}); v.push_back({lgy * x * z, 6}); v.push_back({lgy * z * x, 7}); v.push_back({lgz * pow(x, y), 8}); v.push_back({lgz * pow(y, x), 9}); v.push_back({lgz * x * y, 10}); v.push_back({lgz * y * x, 11}); sort(v.begin(), v.end(), cmp); out = a[v[0].second]; return 0; }
#include <bits/stdc++.h> using namespace std; long double x, y, z, a[12]; int pos; char print[][20] = {"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 >> x >> y >> z; a[0] = pow(y, z) * log(x); a[1] = pow(z, y) * log(x); a[2] = 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[8] = pow(x, y) * log(z); a[9] = pow(y, x) * log(z); a[10] = x * y * log(z); for (int i = 0; i < 11; ++i) if (strlen(print[i]) && a[pos] < a[i]) pos = i; puts(print[pos]); }
#include <bits/stdc++.h> using namespace std; int main() { double x, y, z; double tempx, tempy, tempz; while (cin >> x >> y >> z) { int ans = 0; tempx = x, tempy = y, tempz = z; double start = -INT_MAX; if (log(x) > 0) { if (start < z * log(y) + log(log(x)) - 1e-7) { start = z * log(y) + log(log(x)); } if (start < y * log(z) + log(log(x)) - 1e-7) { start = y * log(z) + log(log(x)); ans = 1; } if (start < log(y * z) + log(log(x)) - 1e-7) { start = log(y * z) + log(log(x)); ans = 2; } } x = tempy, y = tempx; if (log(x) > 0) { if (start < z * log(y) + log(log(x)) - 1e-7) { start = z * log(y) + log(log(x)); ans = 4; } if (start < y * log(z) + log(log(x)) - 1e-7) { start = y * log(z) + log(log(x)); ans = 5; } if (start < log(y * z) + log(log(x)) - 1e-7) { start = log(y * z) + log(log(x)); ans = 6; } } x = tempz, y = tempx, z = tempy; if (log(x) > 0) { if (start < z * log(y) + log(log(x)) - 1e-7) { start = z * log(y) + log(log(x)); ans = 8; } if (start < y * log(z) + log(log(x)) - 1e-7) { start = y * log(z) + log(log(x)); ans = 9; } if (start < log(y * z) + log(log(x)) - 1e-7) { start = log(y * z) + log(log(x)); ans = 10; } } if (x <= 1.0 && y <= 1.0 && z <= 1.0) { x = tempx, y = tempy, z = tempz; double start = pow(x, pow(y, z)); ans = 0; if (start < pow(x, pow(z, y)) - 1e-7) { start = pow(x, pow(z, y)); ans = 1; } if (start < pow(pow(x, y), z) - 1e-7) { start = pow(pow(x, y), z); ans = 2; } x = tempy, y = tempx; if (start < pow(x, pow(y, z)) - 1e-7) { start = pow(x, pow(y, z)); ans = 4; } if (start < pow(x, pow(z, y)) - 1e-7) { start = pow(x, pow(z, y)); ans = 5; } if (start < pow(pow(x, y), z) - 1e-7) { start = pow(pow(x, y), z); ans = 6; } x = tempz, y = tempx, z = tempy; if (start < pow(x, pow(y, z)) - 1e-7) { start = pow(x, pow(y, z)); ans = 8; } if (start < pow(x, pow(z, y)) - 1e-7) { start = pow(x, pow(z, y)); ans = 9; } if (start < pow(pow(x, y), z) - 1e-7) { start = pow(pow(x, y), z); ans = 10; } } switch (ans) { case 0: cout << "x^y^z" << endl; break; case 1: cout << "x^z^y" << endl; break; case 2: cout << "(x^y)^z" << endl; break; case 3: cout << "(x^z)^y" << endl; break; case 4: cout << "y^x^z" << endl; break; case 5: cout << "y^z^x" << endl; break; case 6: cout << "(y^x)^z" << endl; break; case 7: cout << "(y^z)^x" << endl; break; case 8: cout << "z^x^y" << endl; break; case 9: cout << "z^y^x" << endl; break; case 10: cout << "(z^x)^y" << endl; break; case 11: cout << "(z^y)^x" << endl; break; } } return 0; }
#include <bits/stdc++.h> using namespace std; void print(int num) { switch (num) { case 1: cout << "x^y^z"; break; case 2: cout << "x^z^y"; break; case 3: cout << "(x^y)^z"; break; case 4: cout << "(x^z)^y"; break; case 5: cout << "y^x^z"; break; case 6: cout << "y^z^x"; break; case 7: cout << "(y^x)^z"; break; case 8: cout << "(y^z)^x"; break; case 9: cout << "z^x^y"; break; case 10: cout << "z^y^x"; break; case 11: cout << "(z^x)^y"; break; case 12: cout << "(z^y)^x"; break; } } int main() { double x, y, z; cin >> x >> y >> z; int ans = 0; double can = -1 * (1e12); double tmp; if (x > 1) { tmp = z * log(y) + log(log(x)); if (tmp - can > 1e-12) { can = tmp; ans = 1; } tmp = y * log(z) + log(log(x)); if (tmp - can > 1e-12) { can = tmp; ans = 2; } tmp = log((y * z)) + log(log(x)); if (tmp - can > 1e-12) { can = tmp; ans = 3; } } if (y > 1) { tmp = z * log(x) + log(log(y)); if (tmp - can > 1e-12) { can = tmp; ans = 5; } tmp = x * log(z) + log(log(y)); if (tmp - can > 1e-12) { can = tmp; ans = 6; } tmp = log((x * z)) + log(log(y)); if (tmp - can > 1e-12) { can = tmp; ans = 7; } } if (z > 1) { tmp = y * log(x) + log(log(z)); if (tmp - can > 1e-12) { can = tmp; ans = 9; } tmp = x * log(y) + log(log(z)); if (tmp - can > 1e-12) { can = tmp; ans = 10; } tmp = log(y * x) + log(log(z)); if (tmp - can > 1e-12) { can = tmp; ans = 11; } } if (x <= 1 && y <= 1 && z <= 1) { tmp = pow(y, z) * log(x); if (tmp - can > 1e-12) { can = tmp; ans = 1; } tmp = pow(z, y) * log(x); if (tmp - can > 1e-12) { can = tmp; ans = 2; } tmp = (y * z) * log(x); if (tmp - can > 1e-12) { can = tmp; ans = 3; } tmp = pow(x, z) * log(y); if (tmp - can > 1e-12) { can = tmp; ans = 5; } tmp = pow(z, x) * log(y); if (tmp - can > 1e-12) { can = tmp; ans = 6; } tmp = (x * z) * log(y); if (tmp - can > 1e-12) { can = tmp; ans = 7; } tmp = pow(x, y) * log(z); if (tmp - can > 1e-12) { can = tmp; ans = 9; } tmp = pow(y, x) * log(z); if (tmp - can > 1e-12) { can = tmp; ans = 10; } tmp = (y * x) * log(z); if (tmp - can > 1e-12) { can = tmp; ans = 11; } } print(ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long double x, y, z; cin >> x >> y >> z; long double f[12] = { log(x) * pow(y, z), log(x) * pow(z, y), log(x) * y * z, log(x) * z * y, log(y) * pow(x, z), log(y) * pow(z, x), log(y) * x * z, log(y) * z * x, log(z) * pow(x, y), log(z) * pow(y, x), log(z) * x * y, log(z) * y * x}; long double found = f[0]; string p[12] = {"x^y^z", "x^z^y", "(x^y)^z", "(x^z)^x", "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 pos = 0; for (int i = 1; i < 12; i++) { if (found + 0.000000001 < f[i]) { found = f[i]; pos = i; } } cout << p[pos]; return 0; }
#include <bits/stdc++.h> using namespace std; struct trp { long double x, y, z; int ind; void mk(long double a, long double b, long double c, int i) { x = a, y = b, z = c; ind = i; } }; const int N = 12; const long double eps = 1e-15; trp a[N + 10]; 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"}; bool cmp(trp a, trp b) { long double A = log(a.x); long double B = log(b.x); if (abs(A) < eps && abs(B) < eps) return a.ind > b.ind; if (A <= 0 && B > 0) return true; if (A < 0 && B >= 0) return true; if (A > 0 && B <= 0) return false; if (A >= 0 && B < 0) return false; bool flag = false; if (A < 0) { flag = true; A *= -1; B *= -1; } long double AA = log(A) + a.z * log(a.y); long double BB = log(B) + b.z * log(b.y); if (abs(AA - BB) < eps) return a.ind > b.ind; return (AA < BB) ^ flag; } int main() { ios::sync_with_stdio(false); long double x, y, z; cin >> x >> y >> z; a[0].mk(x, y, z, 0); a[1].mk(x, z, y, 1); a[2].mk(x, y * z, 1, 2); a[3].mk(x, z * y, 1, 3); a[4].mk(y, x, z, 4); a[5].mk(y, z, x, 5); a[6].mk(y, x * z, 1, 6); a[7].mk(y, z * x, 1, 7); a[8].mk(z, x, y, 8); a[9].mk(z, y, x, 9); a[10].mk(z, x * y, 1, 10); a[11].mk(z, y * x, 1, 11); sort(a, a + N, cmp); cout << ans[a[N - 1].ind] << "\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 PIL = pair<int, LL>; static constexpr int N = 1000010; template <class T> void in(T& first) { first = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { first = first * 10 + ch - 48; ch = getchar(); } first *= f; } template <class T> inline void out(T first) { if (first < 0) { putchar('-'); first = -first; } if (first > 9) out(first / 10); putchar(first % 10 + '0'); } static string str[] = { "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 cur, ori, first, second, z; int idx = 0; void update(int index) { if (fabs(ori - cur) <= 1e-6) return; if (ori < cur) idx = index, ori = cur; } inline void work() { cin >> first >> second >> z; ori = pow(second, z) * log(first), cur = pow(z, second) * log(first), update(1); cur = z * log(pow(first, second)), update(2); cur = second * log(pow(first, z)), update(3); cur = pow(first, z) * log(second), update(4); cur = pow(z, first) * log(second), update(5); cur = z * log(pow(second, first)), update(6); cur = first * log(pow(second, z)), update(7); cur = pow(first, second) * log(z), update(8); cur = pow(second, first) * log(z), update(9); cur = second * log(pow(z, first)), update(10); cur = first * log(pow(z, second)), update(11); cout << str[idx]; } int main() { work(); return 0; }
#include <bits/stdc++.h> using namespace std; double x, y, z; double a[110]; string s[20]; bool v[20]; int fu; int main() { scanf("%lf%lf%lf", &x, &y, &z); for (int i = 1; i <= 12; i++) v[i] = 1; int c = 0; double maxx = 0; if (x < 1 && y < 1 && z < 1) { a[1] = z * log(y) + log(-log(x)); a[2] = y * log(z) + log(-log(x)); a[3] = log(y * z) + log(-log(x)); a[4] = log(y * z) + log(-log(x)); a[5] = z * log(x) + log(-log(y)); a[6] = x * log(z) + log(-log(y)); a[7] = log(x * z) + log(-log(y)); a[8] = log(x * z) + log(-log(y)); a[9] = y * log(x) + log(-log(z)); a[10] = x * log(y) + log(-log(z)); a[11] = log(x * y) + log(-log(z)); a[12] = log(x * y) + log(-log(z)); for (int i = 1; i <= 12; i++) { if (c == 0 || maxx > a[i]) { maxx = a[i]; c = i; } } } else { if (x < 1) v[1] = v[2] = v[3] = v[4] = 0; if (y < 1) v[5] = v[6] = v[7] = v[8] = 0; if (z < 1) v[9] = v[10] = v[11] = v[12] = 0; if (v[1]) a[1] = z * log(y) + log(log(x)); if (v[2]) a[2] = y * log(z) + log(log(x)); if (v[3]) a[3] = log(y * z) + log(log(x)); if (v[4]) a[4] = log(y * z) + log(log(x)); if (v[5]) a[5] = z * log(x) + log(log(y)); if (v[6]) a[6] = x * log(z) + log(log(y)); if (v[7]) a[7] = log(x * z) + log(log(y)); if (v[8]) a[8] = log(x * z) + log(log(y)); if (v[9]) a[9] = y * log(x) + log(log(z)); if (v[10]) a[10] = x * log(y) + log(log(z)); if (v[11]) a[11] = log(x * y) + log(log(z)); if (v[12]) a[12] = log(x * y) + log(log(z)); for (int i = 1; i <= 12; i++) { if (v[i]) { if (c == 0 || maxx < a[i]) { maxx = a[i]; c = i; } } } } 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"; cout << s[c] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; char s[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[13], b[13], c[13]; bool cmp(int p, int q) { if (c[p] > 1 && c[q] > 1) { return (a[p] * log(b[p]) + log(log(c[p]))) < (a[q] * log(b[q]) + log(log(c[q]))); } else if (c[p] > 1) return false; else if (c[q] > 1) return true; else { long double lef = a[p] * log(b[p]) + log(-log(c[p])); long double rig = a[q] * log(b[q]) + log(-log(c[q])); return lef > rig; } } int main() { long double x, y, z; cin >> x >> y >> z; int ans = 0; a[0] = z; b[0] = y; c[0] = x; a[1] = y; b[1] = z; c[1] = x; a[2] = 1; b[2] = y * z; c[2] = x; a[3] = 1; b[3] = y * z; c[3] = x; a[4] = z; b[4] = x; c[4] = y; a[5] = x; b[5] = z; c[5] = y; a[6] = 1; b[6] = x * z; c[6] = y; a[7] = 1; b[7] = x * z; c[7] = y; a[8] = y; b[8] = x; c[8] = z; a[9] = x; b[9] = y; c[9] = z; a[10] = 1; b[10] = y * x; c[10] = z; a[11] = 1; b[11] = y * x; c[11] = z; for (int i = 1; i < 12; i++) { if (cmp(ans, i)) { ans = i; } } puts(s[ans]); 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; long double x, y, z; long double mx = -10000, t; 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) { mx = t; ans = 2; } t = pow(pow(x, y), z); if (t > mx) { mx = t; ans = 3; } t = pow(y, pow(x, z)); if (t > mx) { mx = t; ans = 5; } t = pow(y, pow(z, x)); if (t > mx) { mx = t; ans = 6; } t = pow(pow(y, x), z); if (t > mx) { mx = t; ans = 7; } t = pow(z, pow(x, y)); if (t > mx) { mx = t; ans = 9; } t = pow(z, pow(y, x)); if (t > mx) { mx = t; ans = 10; } t = pow(pow(z, x), y); if (t > mx) { mx = t; ans = 11; } } else { if (x > 1) { t = z * log(y) + log(log(x)); if (t > mx) { mx = t; ans = 1; } t = y * log(z) + log(log(x)); if (t > mx) { mx = t; ans = 2; } t = log(y) + log(z) + log(log(x)); if (t > mx) { mx = t; ans = 3; } } if (y > 1) { t = z * log(x) + log(log(y)); if (t > mx) { mx = t; ans = 5; } t = x * log(z) + log(log(y)); if (t > mx) { mx = t; ans = 6; } t = log(x) + log(z) + log(log(y)); if (t > mx) { mx = t; ans = 7; } } if (z > 1) { t = y * log(x) + log(log(z)); if (t > mx) { mx = t; ans = 9; } t = x * log(y) + log(log(z)); if (t > mx) { mx = t; ans = 10; } t = log(x) + log(y) + log(log(z)); if (t > mx) { mx = t; ans = 11; } } } cout << s[ans] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; double power1(double x, double y, double z) { double res = pow(y, z) * log(x); return res; } double product1(double x, double y, double z) { double res = (y * z) * log(x); return res; } double power2(double x, double y, double z) { if (x < 1.0) return -1e100; double res = z * log(y) + log(log(x)); return res; } double product2(double x, double y, double z) { if (x < 1.0) return -1e100; double res = log(y * z) + log(log(x)); return res; } bool eq(double a, double b) { return fabs(a - b) < 1e-14; } bool les(double a, double b) { return a + 1e-14 < b; } int main() { double x, y, z; cin >> x >> y >> z; cout.setf(ios::fixed); cout.precision(15); if (eq(max(max(x, y), z), 1.0)) { if (eq(x, 1.0)) { cout << "x^y^z" << endl; } else if (eq(y, 1.0)) { cout << "y^x^z" << endl; } else { cout << "z^x^y" << endl; } return 0; } vector<pair<double, string> > v; if (les(max(max(x, y), z), 1.0)) { v.push_back(make_pair(power1(x, y, z), "x^y^z")); v.push_back(make_pair(power1(x, z, y), "x^z^y")); v.push_back(make_pair(product1(x, y, z), "(x^y)^z")); v.push_back(make_pair(product1(x, z, y), "(x^z)^y")); v.push_back(make_pair(power1(y, x, z), "y^x^z")); v.push_back(make_pair(power1(y, z, x), "y^z^x")); v.push_back(make_pair(product1(y, x, z), "(y^x)^z")); v.push_back(make_pair(product1(y, z, x), "(y^z)^x")); v.push_back(make_pair(power1(z, x, y), "z^x^y")); v.push_back(make_pair(power1(z, y, x), "z^y^x")); v.push_back(make_pair(product1(z, x, y), "(z^x)^y")); v.push_back(make_pair(product1(z, y, x), "(z^y)^x")); } else { v.push_back(make_pair(power2(x, y, z), "x^y^z")); v.push_back(make_pair(power2(x, z, y), "x^z^y")); v.push_back(make_pair(product2(x, y, z), "(x^y)^z")); v.push_back(make_pair(product2(x, z, y), "(x^z)^y")); v.push_back(make_pair(power2(y, x, z), "y^x^z")); v.push_back(make_pair(power2(y, z, x), "y^z^x")); v.push_back(make_pair(product2(y, x, z), "(y^x)^z")); v.push_back(make_pair(product2(y, z, x), "(y^z)^x")); v.push_back(make_pair(power2(z, x, y), "z^x^y")); v.push_back(make_pair(power2(z, y, x), "z^y^x")); v.push_back(make_pair(product2(z, x, y), "(z^x)^y")); v.push_back(make_pair(product2(z, y, x), "(z^y)^x")); } double maxV = v[0].first; string ans = v[0].second; for (int i = 1; i < 12; i++) { if (les(maxV, v[i].first)) { maxV = v[i].first; ans = v[i].second; } } cout << ans << endl; }
#include <bits/stdc++.h> const long double eps = 1e-15; 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"}; long double d[12]; int main() { double _x, _y, _z; scanf("%lf %lf %lf", &_x, &_y, &_z); long double x = _x, y = _y, z = _z; d[0] = powl(y, z) * logl(x); d[1] = powl(z, y) * logl(x); d[2] = d[3] = y * z * logl(x); d[4] = powl(x, z) * logl(y); d[5] = powl(z, x) * logl(y); d[6] = d[7] = x * z * logl(y); d[8] = powl(x, y) * logl(z); d[9] = powl(y, x) * logl(z); d[10] = d[11] = x * y * logl(z); int mx = 0; for (int i = 1; i < 12; ++i) if (d[i] > d[mx] + eps) mx = i; puts(s[mx]); return 0; }
#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; template <typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template <typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const int oo = 0x3f3f3f3f; const int Mod = 1e9 + 7; const int maxn = 100000; const long double eps = 1e-12; long double first, second, z; inline bool eq(const long double &first, const long double &second) { return abs(first - second) < eps || abs(first - second) < eps * abs(first); } int main() { { double a, b, c; scanf("%lf%lf%lf", &a, &b, &c); first = a, second = b, z = c; } long double logx = log(first); long double logy = log(second); long double logz = log(z); long double a[11]; a[0] = logx * pow(second, z); a[1] = logx * pow(z, second); a[2] = logx * second * z; a[3] = a[2]; a[4] = logy * pow(first, z); a[5] = logy * pow(z, first); a[6] = logy * first * z; a[7] = a[6]; a[8] = logz * pow(first, second); a[9] = logz * pow(second, first); a[10] = logz * first * second; long double tmp = -1; int ansp = -1; for (int i = (0), _end_ = (11); i < _end_; ++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; long double x, y, z, ans[13]; void deal(long double x, long double y, long double z, int a) { ans[a + 1] = pow(y, z) * log(x); ans[a + 2] = pow(z, y) * log(x); ans[a + 3] = ans[a + 4] = y * z * log(x); } void output(char x, char y, char z, int a) { if (a == 1) printf("%c^%c^%c\n", x, y, z); else if (a == 2) printf("%c^%c^%c\n", x, z, y); else if (a == 3) printf("(%c^%c)^%c\n", x, y, z); else printf("(%c^%c)^%c\n", x, z, y); } int main() { double x, y, z; while (cin >> x >> y >> z) { deal(x, y, z, 0); deal(y, x, z, 4); deal(z, x, y, 8); int pos = 1; for (int i = 2; i <= 12; i++) if (ans[i] > ans[pos]) pos = i; if (pos <= 4) output('x', 'y', 'z', pos); else if (pos <= 8) output('y', 'x', 'z', pos - 4); else output('z', 'x', 'y', pos - 8); } return 0; }
#include <bits/stdc++.h> using namespace std; char s[20][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]; long double x, y, z; int main() { cin >> x >> y >> z; a[1] = pow(y, z) * log(x); a[2] = pow(z, y) * log(x); a[3] = a[4] = y * z * 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] = y * x * log(z); long double ans = a[1]; int id = 1; for (int i = 2; i <= 12; i++) if (a[i] > ans) { ans = a[i]; id = i; } printf("%s\n", s[id]); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { long double x, y, z; cin >> x >> y >> z; vector<pair<long double, string> > res; if (max(max(x, y), z) > 1.0001) { if (x > 1.0001) { res.push_back({log(log(x)) + log(y) * z, "x^y^z"}); } if (x > 1.0001) { res.push_back({log(log(x)) + log(z) * y, "x^z^y"}); } if (x > 1.0001) { res.push_back({log(log(x)) + log(z * y), "(x^y)^z"}); } if (y > 1.0001) { res.push_back({log(log(y)) + log(x) * z, "y^x^z"}); } if (y > 1.0001) { res.push_back({log(log(y)) + log(z) * x, "y^z^x"}); } if (y > 1.0001) { res.push_back({log(log(y)) + log(z * x), "(y^x)^z"}); } if (z > 1.0001) { res.push_back({log(log(z)) + log(x) * y, "z^x^y"}); } if (z > 1.0001) { res.push_back({log(log(z)) + log(y) * x, "z^y^x"}); } if (z > 1.0001) { res.push_back({log(log(z)) + log(y * x), "(z^x)^y"}); } } else { res.push_back({pow(x, pow(y, z)), "x^y^z"}); res.push_back({pow(x, pow(z, y)), "x^z^y"}); res.push_back({pow(x, y * z), "(x^y)^z"}); res.push_back({pow(y, pow(x, z)), "y^x^z"}); res.push_back({pow(y, pow(z, x)), "y^z^x"}); res.push_back({pow(y, x * z), "(y^x)^z"}); res.push_back({pow(z, pow(y, x)), "z^y^x"}); res.push_back({pow(z, pow(x, y)), "z^x^y"}); res.push_back({pow(z, y * x), "(z^x)^y"}); } stable_sort(res.begin(), res.end(), [](pair<long double, string> t1, pair<long double, string> t2) { return t1.first > t2.first; }); cout << res[0].second; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.setf(ios_base::fixed); cout.precision(28); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 2e6; const int INF = 1e9 + 9; const int B = 1e9 + 7; 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 v[3], ans; int cur, pos; void upd() { long double t = 0, x = v[0], y = v[1], z = v[2]; t = log(x) * pow(y, z); ++cur; if (ans < t) ans = t, pos = cur; t = log(x) * pow(z, y); ++cur; if (ans < t) ans = t, pos = cur; t = log(x) * y * z; ++cur; if (ans < t) ans = t, pos = cur; ++cur; } int main() { ios_base ::sync_with_stdio(0); cin.tie(0); for (int i = int(0); i <= int(2); ++i) cin >> v[i]; ans = -DBL_MAX, pos = 1; upd(); swap(v[0], v[1]); upd(); swap(v[0], v[2]); upd(); cout << s[pos - 1] << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; const int D = 12; int small(int a) { for (int i = 0; i < 3; i++) if (i != a) return i; return -1; } int big(int a) { for (int i = 2; i >= 0; i--) if (i != a) return i; return -1; } string s[3] = {"x", "y", "z"}; string ans(int no) { int first = no / 4; bool has_braces = no % 4 >= 2; int second = no % 2 == 0 ? small(first) : big(first); int third = no % 2 == 0 ? big(first) : small(first); string a = s[first], b = s[second], c = s[third]; return has_braces ? "(" + a + "^" + b + ")^" + c : a + "^" + b + "^" + c; } long double ln_res(int no, long double in[3]) { int first = no / 4; bool has_braces = no % 4 >= 2; int second = no % 2 == 0 ? small(first) : big(first); int third = no % 2 == 0 ? big(first) : small(first); long double a = in[first], b = in[second], c = in[third]; return has_braces ? log(a) * b * c : log(a) * pow(b, c); } const long double EPS = 1E-9; int main() { long double in[3]; double temp; for (int i = 0; i < 3; i++) { cin >> temp; in[i] = temp; } long double mx = ln_res(0, in); int max_no = 0; for (int no = 1; no < 12; no++) { long double curr = ln_res(no, in); if (curr > mx + EPS) { max_no = no; mx = curr; } } cout << ans(max_no); return 0; }
#include <bits/stdc++.h> using namespace std; long double ans[13]; char s[13][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 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 xx = log(x); long double yy = log(y); long double zz = log(z); ans[1] = xx * pow(y, z); ans[2] = xx * pow(z, y); ans[3] = xx * y * z; ans[4] = xx * y * z; ans[5] = yy * pow(x, z); ans[6] = yy * pow(z, x); ans[7] = yy * x * z; ans[8] = yy * x * z; ans[9] = zz * pow(x, y); ans[10] = zz * pow(y, x); ans[11] = zz * x * y; ans[12] = zz * y * x; long double tmp = -1; int id = 0; for (int i = 1; i <= 12; i++) if (tmp < ans[i]) { tmp = ans[i]; id = i; } printf("%s", s[id]); return 0; }
#include <bits/stdc++.h> using namespace std; bool cmp(const pair<long double, string> &a, const pair<long double, string> &b) { return a.first < b.first; } int main() { long double x, y, z; cin >> x >> y >> z; pair<long double, string> vals[9] = { {log(x) * pow(y, z), "x^y^z"}, {log(x) * pow(z, y), "x^z^y"}, {log(x) * y * z, "(x^y)^z"}, {log(y) * pow(x, z), "y^x^z"}, {log(y) * pow(z, x), "y^z^x"}, {log(y) * x * z, "(y^x)^z"}, {log(z) * pow(x, y), "z^x^y"}, {log(z) * pow(y, x), "z^y^x"}, {log(z) * x * y, "(z^x)^y"}}; cout << max_element(vals, vals + 9, cmp)->second << endl; return 0; }
#include <bits/stdc++.h> using namespace std; string printer(int i) { switch (i) { case 0: return "x^y^z"; case 1: return "x^z^y"; case 2: return "(x^y)^z"; case 3: return "(x^z)^y"; case 4: return "y^x^z"; case 5: return "y^z^x"; case 6: return "(y^x)^z"; case 7: return "(y^z)^x"; case 8: return "z^x^y"; case 9: return "z^y^x"; case 10: return "(z^x)^y"; case 11: return "(z^y)^x"; } } long double func(long double a, long double b, long double c, int id) { switch (id) { case 0: return log(a) * pow(b, c); case 1: return log(a) * pow(c, b); case 2: return log(a) * b * c; case 3: return log(a) * c * b; case 4: return log(b) * pow(a, c); case 5: return log(b) * pow(c, a); case 6: return log(b) * a * c; case 7: return log(b) * c * a; case 8: return log(c) * pow(a, b); case 9: return log(c) * pow(b, a); case 10: return log(c) * a * b; case 11: return log(c) * b * a; } } int main() { ::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long double a, b, c; cin >> a >> b >> c; if (a > 2 && b > 2 && c > 2) { vector<pair<long double, int> > v; v.push_back(make_pair(a, 0)); v.push_back(make_pair(b, 1)); v.push_back(make_pair(c, 2)); sort(v.begin(), v.end()); char c[4] = "xyz"; cout << c[v[0].second] << "^" << c[v[1].second] << "^" << c[v[2].second]; return 0; } int id = 0; cout.precision(100); for (int i = 1; i < 12; i++) { if (i == 3) continue; if (i == 7) continue; if (i == 11) continue; if (func(a, b, c, id) < func(a, b, c, i)) id = i; } cout << printer(id); return 0; }
#include <bits/stdc++.h> using namespace std; const int MM = 1e9 + 7; const int INF = INT_MAX; const long double PI = 3.1415926535897; const long double EPS = 1e-12; int n, c; long double x, y, z, res = -1e100; bool ls; string M[] = {"", "x^y^z", "x^z^y", "(x^y)^z", "(x^y)^z", "y^x^z", "y^z^x", "(y^x)^z", "(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y", "(z^x)^y", ""}; void f1(long double xx, long double yy, long double zz, int num) { long double tmp; if (!ls) { tmp = log(log(xx)) + zz * log(yy); } else { tmp = pow(xx, pow(yy, zz)); } if (tmp - res >= EPS) { res = tmp; c = num; } } void f2(long double x, long double y, long double z, int num) { long double tmp; if (!ls) { tmp = log(y * z * log(x)); } else { tmp = pow(x, y * z); } if (tmp - res >= EPS) { res = tmp; c = num; } } int main() { cin >> x >> y >> z; ls = x < 3 && y < 3 && z < 3; f1(x, y, z, 1); f1(x, z, y, 2); f2(x, y, z, 3); f1(y, x, z, 5); f1(y, z, x, 6); f2(y, x, z, 7); f1(z, x, y, 9); f1(z, y, x, 10); f2(z, x, y, 11); cout << M[c] << endl; return 0; }