-
-
L - Looking for Taste
- Gym - 101991L
- 题意:N个数选K个是他们的or运算值最大
- 思路:由于k最小为20,而且每个数大小为1e6之内所以任何情况的最大值都不会超过20为全为1.
- 所以在你可选择范围内一定可以把产生最大值的那些数目不超过20个的那些数选出来。
- 因为|运算不会响最大值,全部数字进行 |或 就行了。
-
#include<bits/stdc++.h> using namespace std; int t,n,k,x,ans; int main() { freopen("looking.in","r",stdin); scanf("%d",&t); while(t--) { ans=0; scanf("%d%d",&n,&k); for(int i=1; i<=n; i++) { scanf("%d",&x); ans|=x; } printf("%d\n",ans); } return 0; }
L - Looking for Taste Gym - 101991L -思维-位运算
猜你喜欢
转载自blog.csdn.net/BePosit/article/details/84398453
今日推荐
周排行