- 问答
何意味???
- @ 2025-10-29 20:36:38
#include <bits/stdc++.h>
#define ll long long
using namespace std;
unsigned int n,m,a[100001],b,ans,cnt;
int main(){
ios::sync_with_stdio();
cin.tie();
cin>>n>>m;
for(unsigned int i=1;i<=n;i++){
cin>>a[i];
}
for(unsigned int i=1;i<=m;i++){
cnt=0;
cin>>b;
for(unsigned int j=1;j<=n;j++){
unsigned int c=b&a[j];
if(c!=a[j]){
break;
}
if(c==a[j]){
cnt++;
}
}
if(cnt==n) ans++;
}
cout<<ans;
return 0;
}
2 comments
-
qsq LV 5 @ 2025-12-20 11:36:20
行
-
@ 2025-12-20 11:32:56
数据范围是 , 超时了,得换个思路
#include <bits/stdc++.h> using namespace std; int n, m; int a[100000 + 5]; int b[100000 + 5]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) cin >> b[i]; int now = 0; for (int i = 1; i <= n; i++) for (int d = 0; d <= 29; d++) if (a[i] & (1 << d)) now = now | (1 << d); int ans = 0; for (int i = 1; i <= m; i++) if ((b[i] & now) == now) ans++; cout << ans; return 0; }
- 1