当前位置:网站首页>[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 method of drawing rounded panel with Delphi
- Sensor: MQ-5 gas module measures the gas value (code attached at the bottom)
- 华为设备配置双反射器优化虚拟专用网骨干层
- Restrict cell input type and display format in CXGRID control
- Huawei equipment is configured with CE dual attribution
- QT realizes mind mapping function (II)
- C language conditional compilation routine
- [learning notes] xr872 GUI littlevgl 8.0 migration (display part)
- 1、 Set up Django automation platform (realize one click SQL execution)
- STM32 IIC protocol controls pca9685 steering gear drive board
猜你喜欢

C language compressed string is saved to binary file, and the compressed string is read from binary file and decompressed.

Sqlserver2008 denied select permission on object'***** '(database'*****', schema'dbo')

Luzhengyao, who has entered the prefabricated vegetable track, still needs to stop being impatient

Introduction to Google unit testing tools GTEST and gmoke

dfs与bfs解决宝岛探险

QT realizes mind mapping function (II)

Ten thousand words make it clear that synchronized and reentrantlock implement locks in concurrency

Huawei equipment is configured with IP and virtual private network hybrid FRR

Viewing the ambition of Xiaodu technology from intelligent giant screen TV v86

C语言压缩字符串保存到二进制文件,从二进制文件读取压缩字符串后解压。
随机推荐
Huawei equipment is configured with dual reflectors to optimize the backbone layer of the virtual private network
STM32F103 IIC OLED program migration complete engineering code
[analysis notes] source code analysis of siliconlabs efr32bg22 Bluetooth mesh sensorclient
Introduction to Google unit testing tools GTEST and gmoke
Establishment of microservice development environment
SQL server deletes all tables and all stored procedures in the database
Decoding iFLYTEK open platform 2.0 is a fertile land for developers and a source of industrial innovation
VI keyboard diagram
Configuring virtual private network FRR for Huawei equipment
Padavan mounts SMB sharing and compiles ffmpeg
Anti crawling strategy (IP proxy, setting random sleep time, bilbili video information crawling, obtaining real URLs, processing special characters, processing timestamp, and multithreading)
dfs与bfs解决宝岛探险
Delphi Google API text to speech MP3 file
Sensor: sht30 temperature and humidity sensor testing ambient temperature and humidity experiment (code attached at the bottom)
Huawei equipment configures private IP routing FRR
cin,cin. get(),cin. Summary of the use of getline() and getline()
[the second day of actual combat of smart lock project based on stm32f401ret6 in 10 days] (lighting with library function and register respectively)
In the third quarter, the revenue and net profit increased "against the trend". What did vatti do right?
Restful interface specification annotation of pringboot (2)
Vivo released originos ocean, and the domestic customized system is getting better and better
