当前位置:网站首页>[51nod p3216] Award [bit operation]
[51nod p3216] Award [bit operation]
2022-06-13 09:35:00 【Ayane.】
analysis :
Medals are all 2 2 2 The power of So I just ask how many binary numbers there are for each number 1 1 1
CODE:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define reg register
using namespace std;
typedef long long ll;
int n,x;
int main(){
scanf("%d",&n);
while(n--)
{
int ans=0;
scanf("%d",&x);
while(x)
{
ans+=(x&1);
x>>=1;
}
printf("%d\n",ans);
}
return 0;
}
边栏推荐
- C language: dynamic memory management
- C language: preprocessing in program environment
- Classes and objects -- Inheritance
- Use typescript to complete simple snake eating function
- acwing 790. The third root of a number (dichotomy)
- Trees and binary trees: the concept of binary trees
- Collection of articles on virtualization and cloud computing
- Trees and binary trees: traversal of binary trees
- C language: Simulated Implementation of library function strcpy
- C language: timer principle
猜你喜欢

Classes and objects -- polymorphic

Trees and binary trees: the concept of binary trees

Acwing785. quick sort (sort+ quick sort + merge sort)

Heap

BGP Federation +community

(dp+ memory) acwing 901 skiing

Exercise 7-10 finding specified characters (15 points)

Exporting MySQL data table documents using Navicat

(state compression dp+ binary) acwing 91 Shortest Hamilton path
![1-2 24:00 (20 points) [CSP certification true question]](/img/3b/fe2c0e46dca604e5906d9c5ceabbe3.jpg)
1-2 24:00 (20 points) [CSP certification true question]
随机推荐
Tree and binary tree: basic operation and implementation of binary tree
C language: deep understanding of pointers and arrays
[implementation of depth first search]
@Value does not take effect and extend/implement other classes cannot inject beans manually
Lecture par lots de tous les fichiers vocaux sous le dossier
Jenkins accédant à l'authentification de l'utilisateur openldap
英国出台粮食安全计划抵御粮食供应危机
LeetCode 6098. Count the number of subarrays whose score is less than K (prefix and + binary search)
Trees and binary trees: traversal of binary trees
turtle库的使用数字时钟模拟时钟动态显示
LeetCode 6097. Match after replacing characters (Dictionary)
C language: minesweeping
Resolve importerror:lib*** so--cannot open shared object file: No such... (pycharm/clion reports an error but the shell does not)
Opencv face recognition of ros2 foxy~galactic~humble
马斯克的「元宇宙」梦
Classes and objects -- Inheritance
【最全面详细解释】背包问题详解
LeetCode 6095. 强密码检验器 II
批量读取文件夹下的全部语音文件
C#入门系列(十三) -- 初识结构体

