【题解】牛客练习赛67 B.牛牛爱位运算
牛牛爱位运算
https://ac.nowcoder.com/acm/contest/6885/B
题目
思路
位运算。
这题考察位运算的知识。
由此可得两个数进行 操作只会使得最后的结果变小或者不变,不可能变大,所以最后答案就是一开始序列中最大的数。
Code
#include <cstdio> #include <cstring> #include <string> #include <iostream> #include <algorithm> int max(int a, int b) { return a > b ? a : b; } int main() { int t, n; scanf("%d", &t); while(t--) { scanf("%d", &n); int ans = 0; for (int i = 1, x; i <= n; ++i) { scanf("%d", &x); ans = max(ans, x); } std::cout << ans << '\n'; } return 0; }