版本比较
编译器
正文
增加 53 行删除 21 行
11234516 行未改动22232425262727282929303132333460 行未改动95969798989910010110210316 行未改动12012112212312312412512612712840 行未改动1691701711721721731741751761771782 行未改动18118218318418518618718818928 行未改动2182192202212222232242252262272282292302312322332342352362372382392202402412422432442452462272472482492504 行未改动2552562572582402592602422612622632642652 行未改动26826927027125327227327427527611 行未改动28828929029127329229329429529629729828029930030130230350 行未改动354355356357339358359360342361362363364346365366367368369146 行未改动全部展开51651751851950150252052152252352452569 行未改动595596597598580599600601602603157 行未改动全部展开7617627637647467657667677687697707717727737747757767777787797807817827837844 行未改动7897907917927617937947957967976 行未改动```cpp```cpp line-numbers#include<bits/stdc++.h>#include<summer02.h>#define pre(i, l, r) for(int i = (l); i <= (r); ++i)#define fpre(i, r, l) for(int i = (r); i >= (l); --i)16 行未改动const int MB = 8;map<string,int> f;int cnt = 0;vector<ll> value(MB * 131072 + 1);map<string, pair<int,int>> gf;
string st[maxn] = string st[maxn] ={
};
ll qpow(ll a, ll b, ll p = 0){60 行未改动 x++; } while(x < sz && isdigit(s[x])) ans = ans * 10 + (s[x++] ^ 48); if(!f) ans = -ans; return ans; return ans;}
ll strvalue(string x);
16 行未改动}
ll _strvalue(string s){ int x = 0, Y = 0, Z = 0, P = 0; int x = 0, Y = 0, Z = 0, P = 0; fr(i, s) { char y = s[i]; if(y == '(')40 行未改动 return _strvalue(s.substr(1, s.size() - 2)); return strvalue(s);}
ll strvalue(string x);inline void tovalue(string& s);ll solve(int L, int R);
ll gcd(ll a, ll b){ if(!b)2 行未改动}
ll strfunction(string f, string c){ printf("f:%s\nc:%s\n", f.c_str(), c.c_str()); if(f == "qpow" || f == "pow") { string a = str(c, 0), b = str(c, 1 + a.size()), p = str(c, 2 + a.size() + b.size()); return qpow(strvalue(a), strvalue(b), strvalue(p));28 行未改动 { string a = str(c, 0), b = str(c, 1 + a.size()); return strvalue(a) / gcd(strvalue(a), strvalue(b)) * strvalue(b); } int l = gf[f].first, functionres = 10 + f.size(), nowres = 0; map<string,ll> beifen; vector<string> tt; while(str(st[l - 1], functionres) != "") { string t = str(c, nowres); beifen[t] = strvalue(t); if(!::f[str(st[l - 1], functionres)]) ::f[str(st[l - 1], functionres)] = ++cnt, tt.push_back(str(st[l - 1], functionres)); value[::f[str(st[l - 1], functionres)]] = strvalue(t); nowres += t.size() + 1; functionres += str(st[l - 1], functionres).size() + 1; } ll ans = solve(gf[f].first + 1, gf[f].second - 1); for(auto y : tt) ::f[y] = 0; for(auto y : beifen) value[::f[y.first]] = y.second; return 0; return ans;}
ll strvalue(string x){ if(x == "") return 0; bool ok = true; fr(i, x) if(!isdigit(x[i]) && i != 0) ok = false;4 行未改动 if(f[x]) return value[f[x]]; ok = false; fr(i, x) if(i != 0 && x[i] == '(' && (islower(x[i - 1]) || isupper(x[i - 1]) || isdigit(x[i - 1]))) if(i != 0 && x[i] == '(' && (!isdigit(x[i - 1]) && x[i - 1] != '+' && x[i - 1] != '-' && x[i - 1] != '*' && x[i - 1] != '/' && x[i - 1] != '^' && x[i - 1] != '|' && x[i - 1] != '&')) ok = true; if(ok) if(ok || ~x.find('.')) { string f = ""; int u = 0; fr(i, x)2 行未改动 u = i; break; } fpre(i, u - 1, 0) if(!islower(x[i]) && !isupper(x[i]) && !isdigit(x[i])) if(!islower(x[i]) && !isupper(x[i]) && !isdigit(x[i]) && x[i] != '.' && x[i] != '_') break; else f += x[i]; reverse(f.begin(), f.end());11 行未改动 } if(x[i] == ',' && tot == 1) { if(number != "") c += number + ' '; c += to_string(strvalue(number)) + ' '; number = ""; } else number += x[i]; } if(number != "") c += number;//(qpow(a,b)+3)%6 c += to_string(strvalue(number));//(qpow(a,b)+3)%6 return strvalue(x.substr(0, u - f.size()) + to_string(strfunction(f, c)) + x.substr(r + 1, x.size())); } int l = 0, r = 0, tot = 0; string name = "";50 行未改动 else name += s[i]; reverse(name.begin(), name.end()); if(l) s = s.substr(0, l - name.size()) + name + "[" + to_string(strvalue(s.substr(l + 1, r - l - 1))) + "]" + s.substr(r + 1, s.size()); s = s.substr(0, l - name.size()) + name + "[" + to_string(strvalue(s.substr(l + 1, r - l - 1))) + "]" + s.substr(r + 1, s.size());}
inline void solve(int L, int R)ll solve(int L, int R){ pre(i, L, R) { string s = st[i - 1]; string &s = st[i - 1]; fr(i, s) if(i != _ - 1 && s[i] == '/' && s[i + 1] == '/') { s.erase(i, s.size());146 行未改动全部展开 if(s.size() != 7) print(s.substr(8, s.size())); } else if(op == "exit") return; if(op == "exit" || op == "return") return strvalue(str(s, op.size())); else if(op == "puts") { if(s.size() == 4)69 行未改动 } } } else if(op == "endfor") if(op == "endfor") { int tot = 1, u; fpre(j, i - 1, L) {157 行未改动全部展开 } else if(op == "function") { fr(i, s) if(s[i] == ',' || s[i] == '(' || s[i] == ')') s[i] = ' '; string name = str(s, 8); gf[name].first = i; while(i < R && st[i - 1] != "endfunction") i++; gf[name].second = i; } else if(op == "system") { system(s.substr(7, s.size()).c_str()); }
} return 0;}
int main(){4 行未改动 f["INT_MAX"] = ++cnt, value[cnt] = INT_MAX; f["LLONGMAX"] = ++cnt, value[cnt] = LLONG_MAX; f["INT_MIN"] = ++cnt, value[cnt] = INT_MIN; f["LLONG_MAX"] = ++cnt, value[cnt] = LLONG_MAX; while(st[n] != "") ++n; pre(i, 0, 2000) if(st[i] != "") n = i + 1; if(!n) { while(getline(cin, st[n++])); n--;6 行未改动