标签:set test integer msu names inpu output ane ssi
InputThe 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) followOutputOutput 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
题意:给N个数 每个数都可以拆开成一个32位的2进制 每八位一个字节 每个字节的2进制数换算成十进制的看有多少个97
思路:CillyB: % 256是看看后8位是多少, /= 256是去掉后8位
1 #include <iostream>
2 #include <cstdio>
3 using namespace std;
4
5 int main()
6 {
7 int ans,n,x;
8 int i;
9 cin>>n;
10 ans=0;
11 for(i=0;i<n;i++)
12 {
13 scanf("%d",&x);
14 while(x)
15 {
16 if(x%256==97)
17 {
18 ans++;
19 }
20 x/=256;
21 }
22 }
23 cout<<ans<<endl;
24 }
标签:set test integer msu names inpu output ane ssi
原文地址:http://www.cnblogs.com/--lr/p/6850523.html