主页 > 电脑硬件  > 

3475相或为k

3475相或为k
3475相或为k

⭐️难度:困难 🌟考点:位运算 📖

📚

import java.util.Scanner; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt();//循环的数 int k = sc.nextInt();//给的或(数) int num = 0; for(int i=1;i<=n;i++) { int r =sc.nextInt(); if((r&k)==r) { // r有1的位置k也刚好有1 num = num | r; } } if(num==k) { System.out.println("Yes"); }else { System.out.println("No"); } } } }

🍎笔记

标签:

3475相或为k由讯客互联电脑硬件栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“3475相或为k