HDU 5980 Find Small A(寻找小A)

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

 

Problem Description - 题目描述

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).
众所周知,字符 'a' 的ASCII码为97.现在,找出给定数组中出现了多少次 'a' 。注意,此处的数字为计算机中的32位整数。这表示,1个数字由四个字符组成(一个字符由8位二进制数组成)。

CN

Input - 输入
The input contains a set of test data.The first number is one positive integer N (1≤N≤100),and then N positive integers ai (1≤ ai≤2^32 - 1) follow.
只有一组输入数据。第一个数为一个正整数N (≤N≤),随后有N个正整数ai (≤ ai≤^ - )。

CN

Output - 输出

Output one line,including an integer representing the number of 'a' in the group of given numbers.
输出一行一个整数,表示数组中 'a' 出现的次数。

CN

Sample Input - 输入样例

3
97 24929 100

Sample Output - 输出样例

3

题解

  水题。
  一个数可以拆成4个字符,判断这4个字符是不是’a’,统计一下即可。
  刚开始被括内的二进制解释误导了,还以为要从二进制下一位一位地寻找匹配,信手一发KMP直接翻车……

代码 C++

 #include<cstdio>
int main(){
int t, i, opt = ;
unsigned int a;
scanf("%d", &t);
while (t--){
for (i = scanf("%u", &a); i < ; ++i){
if ((a & 0xFF) == 'a') ++opt;
a >>= ;
}
}
printf("%d\n", opt);
return ;
}

HDU 5980 Find Small A(寻找小A)的更多相关文章

  1. hdu 5008 查找字典序第k小的子串

    Boring String Problem Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  2. 2016级算法第六次上机-A.Bamboo之寻找小金刚

    Bamboo之寻找小金刚 分析 可以抽象为许多连续线段,分别计数左拐和右拐的个数.考察叉积的基础应用. 假设ABC三点构成一个夹角∠ABC,B就是拐点,AC是辅助形成夹角.考虑线段AB和BC形成的向量 ...

  3. HDU 2072 - 单词数 - [(有点小坑的)字典树模板题]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2072 Problem Descriptionlily的好朋友xiaoou333最近很空,他想了一件没有 ...

  4. HDU 6038 Function(思维+寻找循环节)

    http://acm.hdu.edu.cn/showproblem.php?pid=6038 题意:给出两个序列,一个是0~n-1的排列a,另一个是0~m-1的排列b,现在求满足的f的个数. 思路: ...

  5. hdu 4704 sum(费马小定理+快速幂)

    题意: 这题意看了很久.. s(k)表示的是把n分成k个正整数的和,有多少种分法. 例如: n=4时, s(1)=1     4 s(2)=3     1,3      3,1       2,2 s ...

  6. 题解报告:hdu 6440 Dream(费马小定理+构造)

    解题思路:给定素数p,定义p内封闭的加法和乘法运算(运算封闭的定义:若从某个非空数集中任选两个元素(同一元素可重复选出),选出的这两个元素通过某种(或几种)运算后的得数仍是该数集中的元素,那么,就说该 ...

  7. HDU 4704 Sum( 费马小定理 + 快速幂 )

    链接:传送门 题意:求 N 的拆分数 思路: 吐嘈:求一个数 N 的拆分方案数,但是这个拆分方案十分 cd ,例如:4 = 4 , 4 = 1 + 3 , 4 = 3 + 1 , 4 = 2 + 2 ...

  8. hdu 5335 Walk Out(bfs+寻找路径)

    Problem Description In an n∗m maze, the right-bottom corner or a written on it. An explorer gets los ...

  9. hdu 4704 Sum 【费马小定理】

    题目 题意:将N拆分成1-n个数,问有多少种组成方法. 例如:N=4,将N拆分成1个数,结果就是4:将N拆分成2个数,结果就是3(即:1+3,2+2,3+1)--1+3和3+1这个算两个,则这个就是组 ...

随机推荐

  1. CentOS 7 安装 nginx

    一.安装nginx依赖lib库: 1.yum install gcc-c++ -y 2.yum install pcre pcre-devel -y 3.yum install zlib zlib-d ...

  2. 错误 You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work

    Win  10    下python3.6 使用Beautiful Soup  4错误 You are trying to run the Python 2 version of Beautiful ...

  3. Sprint

    Sprint冲刺 1.选题 <寿司点餐系统> 2.app名 <Sushi> 3.团名 ZEG 4.目标 制作一个成型的人性化的寿司点餐系统,介绍各种寿司的材料做法吃法以及价格, ...

  4. 注解的方式搭建springmvc步骤

    1.cope   jar包到lib中 2.配置web.xml文件 <servlet> <servlet-name>springmvc</servlet-name> ...

  5. Slackware Linux or FreeBSD 配置中文环境。

    配置中文环境. Slackware Linux 如果在控制面板的语言与地区选项中没有找到中文,那说明在安装系统选择软件的时候没有将国际语言支持包选上,可以从slackware的安装盘或ISO文件中提取 ...

  6. Java Thread wait, notify and notifyAll Example

    Java Thread wait, notify and notifyAll Example Java线程中的使用的wait,notify和nitifyAll方法示例. The Object clas ...

  7. Coursera台大机器学习课程笔记6 -- The VC Dimension

    本章的思路在于揭示VC Dimension的意义,简单来说就是假设的自由度,或者假设包含的feature vector的个数(一般情况下),同时进一步说明了Dvc和,Eout,Ein以及Model C ...

  8. CSS中隐藏内容的3种方法及属性值

    CSS中隐藏内容的3种方法及属性值 (2011-02-11 13:33:59)   在制作网页时,隐藏内容也是一种比较常用的手法,它的作用一般有:隐藏文本/图片.隐藏链接.隐藏超出范围的内容.隐藏弹出 ...

  9. Android 常用操作

    0.android studios使用介绍 使用介绍 android studio 常用小技巧 网址 1.怎么样添加第三方库 方法一: 第一步:将第三方库以module的形式导入 第二步:选中要导入第 ...

  10. 6.Git内容修改之后的查看和提交

    我们已经成功地添加并提交了一个readme.txt文件,现在,是时候继续工作了,于是,我们继续修改readme.txt文件,改成如下内容: Git is a distributed version c ...