10.23拼多多笔试统计
hr说我笔试不通过,这算自找苦吃了,原本能做第四题的,以为三道稳过就不做了,吸取教训吧我这是。
。。。。。。。。。。。。。。。。
1 1 1 0.15 ,最后一题看着蛮简单的,但不想做了。
附第三题代码:
#include<bits/stdc++.h> using namespace std; int main() { int n, mm; cin >> n >> mm; vector<int> v(mm, -2);; for (int i = 0; i < n; i++) { char c; int op; cin >> c >> op; if (c == '&') { for (int ii = 0; ii < mm; ii++) { if ((op >> ii) & 1) {} else v[ii]=0; } } else if (c == '|') { for (int ii = 0; ii < mm; ii++) { if ((op >> ii) & 1) v[ii] = 1; } } else { for (int ii = 0; ii < mm; ii++) { if ((op >> ii) & 1) { if (v[ii] == -2) v[ii] = -1; else if (v[ii] == 1) v[ii] = 0; else v[ii] = 1; } } } } int l = 0, m = 0, r = 0; for (auto k : v) { if (k == 0) l = 1; else if (k == 1) m = 1; else if (k == -1) r == 1; } int l2 = (1 << mm)-1; int m2 = 0, r2 = 0; for (int i = 0; i < mm; i++) { if (v[i] == 0) { l2 ^= (1 << i); } else if (v[i] == 1) { m2 |= (1 << i); } else if (v[i] == -1) { r2 |= (1 << i); } } cout << l + m + r << endl; if (l)cout << '&' << ' ' << l2 << endl; if (m) cout << '|' << ' ' << m2 << endl; if (r) cout << '^' << ' ' << r2 << endl; }