public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNext()) { // 注意 while 处理多个 case int a = in.nextInt(); int count =0; // 进行与运算 for (int i=0;i<32;i++) { int n=(int)Math.pow(2,i); if ((n&a)==n) { count++; } } System.out.print(count); } } } 我感觉我这种解法思路更优
点赞

相关推荐

程序员牛肉:你这简历有啥值得拷打的?在牛客你这种简历一抓一大把,也就是个人信息不一样而已。 关键要去找亮点,亮点啊,整个简历都跟流水线生产出来的一样。
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务