题意:众所周知,字符 'a' 的ASCII码为97.现在,找出给定数组中出现了多少次 'a' 。注意,此处的数字为计算机中的32位整数。这表示,

1个数字由四个字符组成(一个字符由8位二进制数组成)。

析:直接用运用位运算即可。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e16;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
string str;
for(int i = 0; i < 8; ++i)
str.push_back((97&(1<<i)) ? '1' : '0');
int T; cin >> T;
int ans = 0;
while(T--){
string s;
LL n;
cin >> n;
for(int i = 0; i < 32; ++i)
s.push_back((n&(1LL<<i)) ? '1' : '0');
for(int i = 0; i < 32; i += 8)
if(str == s.substr(i, 8)) ++ans;
}
cout << ans << endl;
return 0;
}

  

HDU 5980 Find Small A (水题)的更多相关文章

  1. HDU 5578 Friendship of Frog 水题

    Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  2. HDU 5590 ZYB's Biology 水题

    ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  3. HDU 5538 L - House Building 水题

    L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  4. hdu 1005:Number Sequence(水题)

    Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  5. hdu 1018:Big Number(水题)

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  6. hdu 2041:超级楼梯(水题,递归)

    超级楼梯 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...

  7. HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)

    Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...

  8. HDOJ(HDU) 2090 算菜价(简单水题、)

    Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...

  9. HDOJ(HDU) 1555 How many days?(水题)

    Problem Description 8600的手机每天消费1元,每消费K元就可以获赠1元,一开始8600有M元,问最多可以用多少天? Input 输入包括多个测试实例.每个测试实例包括2个整数M, ...

随机推荐

  1. 删除power by dedecms的方法

    在include/dedesql.class.php文件,会发现最新的include/dedesql.class.php文件会多出第588到第592行的那几段代码,代码如下图: $arrs1 = ar ...

  2. Spring Cloud2.0之整合Consul作为注册中心

    使用Consul来替换Eureka Consul简介 Consul 是一套开源的分布式服务发现和配置管理系统,由 HashiCorp 公司用 Go 语言开发. 它具有很多优点.包括: 基于 raft ...

  3. MapReduce分区的使用(Partition)

    MapReduce中的分区默认是哈希分区,根据map输出key的哈希值做模运算,如下 int result = key.hashCode()%numReduceTask; 如果我们需要根据业务需求来将 ...

  4. codevs 1299 切水果 线段树

    1299 切水果  时间限制: 1 s  空间限制: 128000 KB     题目描述 Description 简单的说,一共N个水果排成一排,切M次,每次切[L,R]区间的所有水果(可能有的水果 ...

  5. 英语发音规则---oo

    英语发音规则---oo 一.总结 一句话总结: 1.重读音节词尾的字母组合oo发音素[u:]的音? too [tu:] adv.太;也 zoo [zu:] n.动物园 room [ru:m] n.房间 ...

  6. input 限制输入

    只能输入数字 :<input type="text" onkeyup="value=value.replace(/[^\d]/g,'')" /> 只 ...

  7. bootstrap-自定义导航栏隐藏参数@screen-sm

    导航菜单默认在屏幕小于768px的时候自动折叠,怎么自定义这个大小? 需要重新编译bootstrap 编译 CSS 和 JavaScript 文件 问题解决!

  8. 超链接向servlet传参数

    超链接传参数方式如下: <a href=xxxServlet?flag=1  target=“XX”></a> 注意:target=“XX”是用来指定在什么窗体打开.xx为该窗 ...

  9. 不要使用Android Studio的Git Commit了---->记一次debug

    今天下午写了一些代码,吃晚饭时分用Android Studio commit了一下,不知道有没有选择Commit and push,结果刚才代码出bug我想回滚到上个版本的时候,发现Android S ...

  10. python suds 调用webservice 缓存

    在linux系统中 如果webservice更新了字段 suds调用有可能缓存以前的字段或方法,对新的字段报找不到类型 TypeNotFound,或者对 新加的方法找不到该方法的错误. 当更新或添加w ...