A.
Find Small A
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 3868 Accepted Submission(s): 1743
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).
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
3
97 24929 100
Sample Output
3
题目比较简单, 就是位运算, 直接上代码。
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){//32位拆成四个 8进制 , 看谁是97
int t, a;
cin >> t;
int cnt = 0;
while(t--){
cin >> a;
while(a){
if(a % 256 == 97)
cnt++;
a /= 256;
}
}
cout<< cnt <<endl;
}
D.
Children’s Day
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2922 Accepted Submission(s): 1826
Problem Description
Today is Children’s Day. Some children ask you to output a big letter ‘N’. ‘N’ is constituted by two vertical linesand one diagonal. Each pixel of this letter is a character orderly. No tail blank is allowed.
For example, this is a big ‘N’ start with ‘a’ and it’s size is 3.
a e
bdf
c g
Your task is to write different ‘N’ from size 3 to size 10. The pixel character used is from ‘a’ to ‘z’ continuously and periodic(‘a’ is reused after ‘z’).
Input
This problem has no input.
Output
Output different ‘N’ from size 3 to size 10. There is no blank line among output.
Sample Output
[pre]
a e
bdf
c g
h n
i mo
jl p
k q
.........
r j
[/pre]
Hint
Not all the resultsare listed in the sample. There are just some lines. The ellipsis expresseswhat you should write.
Source
2013 ACM/ICPC Asia Regional Online —— Warmup
这个模拟题,我直接暴力…
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
printf("a e\nbdf\nc g\nh n\ni mo\njl p\nk q\nr z\ns ya\nt x b\nuw c\nv d\ne o\nf np\ng m q\nh l r\nik s\nj t\nu g\nv fh\nw e i\nx d j\ny c k\nzb l\na m\nn b\no ac\np z d\nq y e\nr x f\ns w g\ntv h\nu i\nj z\nk ya\nl x b\nm w c\nn v d\no u e\np t f\nqs g\nr h\ni a\nj zb\nk y c\nl x d\nm w e\nn v f\no u g\np t h\nqs i\nr j\n");
return 0;
}