2016ICPC大连站 J Find Small A【water】
来源:互联网 发布:人类实验室 网络暴力 编辑:程序博客网 时间:2024/05/22 15:46
As is known to all,the ASCII of character ‘a’ is 97. Now,find out how many character ‘a’ in a group of given numbers. Please note that the numbers here are given by 32 bits’ integers in the computer.That means,1digit represents 4 characters(one character is represented by 8 bits’ binary digits).
Input
The input contains a set of test data.The first number is one positive integer N (1≤N≤100),and then N positive integersai (1≤ aiai≤2^32 - 1) follow
Output
Output one line,including an integer representing the number of ‘a’ in the group of given numbers.
Sample Input
3
97 24929 100
Sample Output
3
把32位的数字分成 四个八位数字 计算这四个二进制数 有几个97
最后sum求和
#include<iostream>#include<cstring>#include<algorithm>using namespace std;int a[64];int b[64];int c[8]={1,0,0,0,0,1,1,0};int n;int t;int k=0;void solve(){ memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); while(n) { a[k++]=n%2; n/=2; } for(int i=0;i<32;i++) { b[i]=a[i]; }}int main(){ while(cin>>t) { int ans=0; while(t--) { cin>>n; k=0; solve();bool flag1=1,flag2=1,flag3=1,flag4=1; for(int i=0;i<8;i++) if(b[i]!=c[i]) flag1=0; for(int i=8;i<16;i++) if(b[i]!=c[i-8]) flag2=0; for(int i=16;i<24;i++) if(b[i]!=c[i-16]) flag3=0; for(int i=24;i<32;i++) if(b[i]!=c[i-24]) flag4=0; ans+=flag1+flag2+flag3+flag4; } cout<<ans<<endl; } return 0;}
阅读全文
0 0
- 2016ICPC大连站 J Find Small A【water】
- HDU 5980 && 2016ICPC大连 J: Find Small A
- 【HDU 5980 Find Small A】+ 2016ACM/ICPC亚洲区大连站-重现赛(感谢大连海事大学)
- 2016ICPC大连站 A
- 2016ACM/ICPC亚洲区大连站 J
- 2016ICPC大连站 H
- HDU5980 Find Small A
- 2016 ICPC 大连站解题报告
- 2016ICPC大连站 F Detachment【数学】
- 2016ICPC大连站 I Convex【几何】
- 2016ICPC大连站 D A Simple Math Problem【GCC+方程】
- HDU 5974 && 2016ICPC大连 D: A Simple Math Problem
- hdu 5980 Find Small A
- HDU 5980 Find Small A
- Hdu-5980-Find Small A
- HDU 5980 Find Small A
- HDU 5980 Find Small A
- hdu5890 Find small A 二进制
- XGBoost参数调优完全指南(附Python代码)
- hive分组排序 取top N
- JSON入门Java篇-6-对JSON数据进行解析操作
- 《C++ Concurrency in Action》笔记24 std::atomic<T*>、std::atomic<整型>
- java语言编写的基本排序算法
- 2016ICPC大连站 J Find Small A【water】
- sqoop数据加载
- spoj Query on a tree2(LCA)
- 设置路由器 从外网访问内网服务器 端口映射
- 装配Bean——隐式的bean发现机制和自动装配
- 这段时间就回顾下已经快被忘记的知识点吧,首先是关于死锁
- java中的几种IO读取方法
- c++笔记——MFC基础(暂存)
- 博客第一天,开启机器生活