当前位置:网站首页>[51nod.3210] binary Statistics (bit operation)
[51nod.3210] binary Statistics (bit operation)
2022-06-13 02:06:00 【Python's path to becoming a God】
Binary statistics
sample input
5
1
2
4
8
16
sample output
1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Their thinking
Binary system
AC Code
#include<cstdio>
using namespace std;
int n,ans[32];
int main()
{
scanf("%d",&n);
while(n--)
{
int x,sum=0;
scanf("%d",&x);
x&=-x;
x>>=1;
while(x)
{
x>>=1;
sum++;
}
ans[sum]++;
}
for(int i=0;i<=31;i++)
printf("%d ",ans[i]);
return 0;
}
thank you
边栏推荐
- The new wild prospect of JD instant retailing from the perspective of "hour shopping"
- STM32 external interrupt Usage Summary
- Parameter measurement method of brushless motor
- Combining strings and numbers using ssstream
- Devaxpress Chinese description -- tdxgallerycontrol object (gallery component)
- Looking at Qianxin's "wild prospect" of network security from the 2021 annual performance report
- Magics 23.0如何激活和使用视图工具页的切片预览功能
- QT realizes mind mapping function (II)
- Huawei equipment is configured with CE dual attribution
- Ruixing coffee moves towards "national consumption"
猜你喜欢
[the fourth day of actual combat of stm32f401ret6 smart lock project in 10 days] voice control is realized by externally interrupted keys
Magics 23.0如何激活和使用视图工具页的切片预览功能
Magics 23.0 how to activate and use the slice preview function of the view tool page
The new wild prospect of JD instant retailing from the perspective of "hour shopping"
Sensorless / inductive manufacturing of brushless motor drive board based on stm32
10 days based on stm32f401ret6 smart lock project practice day 1 (environment construction and new construction)
The scientific innovation board successfully held the meeting, and the IPO of Kuangshi technology ushered in the dawn
Record: how to solve the problem of "the system cannot find the specified path" in the picture message uploaded by transferto() of multipartfile class [valid through personal test]
Devaxpress Chinese description --tcxpropertiesstore (property store recovery control)
[learning notes] xr872 GUI littlevgl 8.0 migration (display part)
随机推荐
LeetCode每日一题——890. 查找和替换模式
C language volatile learning
移动IPv6光猫登录的一般ip地址账号与密码,移动光猫变桥接模式
What is Google plus large text ads? How to use it?
PyFlink实现自定义SourceFunction
When AI meets music, iFLYTEK music leads the industry reform with technology
Qt实现思维导图功能(二)
10 days based on stm32f401ret6 smart lock project practice day 1 (environment construction and new construction)
Pyflink implements custom sourcefunction
Restful interface specification annotation of pringboot (2)
Devexpress implementation flow chart
Read routing table
Luzhengyao, who has entered the prefabricated vegetable track, still needs to stop being impatient
SQLserver2008 拒绝了对对象 '****' (数据库 '****',架构 'dbo')的 SELECT 权限
[the second day of actual combat of smart lock project based on stm32f401ret6 in 10 days] GPIO and register
How to solve the problem of obtaining the time through new date() and writing out the difference of 8 hours between the database and the current time [valid through personal test]
[the 4th day of the 10 day smart lock project based on stm32f401ret6] what is interrupt, interrupt service function, system tick timer
How does Google's audience work?
Review the history of various versions of ITIL, and find the key points for the development of enterprise operation and maintenance
Application and examples of C language structure