結果
| 問題 | 
                            No.193 筒の数式
                             | 
                    
| コンテスト | |
| ユーザー | 
                             not_522
                         | 
                    
| 提出日時 | 2015-08-03 23:45:47 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,961 bytes | 
| コンパイル時間 | 1,910 ms | 
| コンパイル使用メモリ | 177,856 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-18 01:10:01 | 
| 合計ジャッジ時間 | 2,295 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 11 WA * 5 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline T toInteger(const string&);
template<> inline int toInteger<int>(const string& s) {
  return stoi(s);
}
template<> inline long toInteger<long>(const string& s) {
  return stol(s);
}
template<> inline long long toInteger<long long>(const string& s) {
  return stoll(s);
}
template<typename T = long long> inline T toInteger(const string& s, int n) {
  T res = 0;
  for (char c : s) {
    if (isdigit(c)) res = res * n + c - '0';
    else if (isalpha(c)) res = res * n + tolower(c) - 'a' + 10;
  }
  return s[0] == '-' ? -res : res;
}
template<typename T = long long> class Parser {
private:
  string s;
  int p;
  vector<map<char, function<T(T, T)>>> ope;
  T term() {
    if (s[p] == '(') {
      ++p;
      T res = expr(0);
      ++p;
      return res;
    }
    string res = "";
    for (; isdigit(s[p]); ++p) res += s[p];
    return toInteger<T>(res);
  }
  T expr(int level) {
    if (level == (int)ope.size()) return term();
    T res = expr(level + 1);
    for (char c; c = s[p++], ope[level].count(c);) res = ope[level][c](res, expr(level + 1));
    --p;
    return res;
  }
public:
  void addOperator(function<T(T, T)> func, char c, int level) {
    if ((int)ope.size() <= level) ope.resize(level + 1);
    ope[level][c] = func;
  }
  long long parse(const string& s) {
    this->s = s + '@';
    p = 0;
    return expr(0);
  }
};
template<typename T = long long> inline T parse(const string& s) {
  Parser<T> parser;
  parser.addOperator(plus<T>(), '+', 0);
  parser.addOperator(minus<T>(), '-', 0);
  parser.addOperator(multiplies<T>(), '*', 1);
  parser.addOperator(divides<T>(), '/', 1);
  return parser.parse(s);
}
int main() {
  string s;
  cin >> s;
  long long res = 0;
  for (size_t i = 0; i < s.size(); ++i) {
    if (isdigit(s[0]) && isdigit(s.back())) res = max(res, parse(s));
    rotate(s.begin(), s.begin() + 1, s.end());
  }
  cout << res << endl;
}
            
            
            
        
            
not_522