本文共 1355 字,大约阅读时间需要 4 分钟。
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≤ ai≤2^32 - 1) follow
Output
Output one line,including an integer representing the number of 'a' in the group of given numbers.
Sample Input
397 24929 100
Sample Output
3
给你n个32位整数,每个整数可以表示成4个字符(因为一个字符在计算机中占8位),问n个整数共包含多少个字符'a'
由于一个字符占二进制8位,所以每个整数相当于转化为2^8=256进制数
那么将32位整数循环对256取模,看是不是97(字符'a')即可
把256换成10 进行10进制的运算一下就看懂了
/*Sherlock and Watson and Adler*/#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include #include #include #include #include #include #include
转载地址:http://aotgn.baihongyu.com/