2018 Ninth Blue Bridge Cup C/C++ Programming Undergraduate Group B Provincial Competition Topics Summary

1. January 1, 2000, is the first day of that year. So, on May 4, 2000, what day was it in that year?
Note: What needs to be submitted is an integer, do not fill in any redundant content.
Calculated directly or with the help of an Excel table, January 1, 2000 plus 124 days = May 4, 2000, so it is the 125th day
2. Title:
The glyphs of clear Chinese characters exist in the font library, even today, the 16-dot matrix The font library is still widely used.
The 16-dot font library regards each Chinese character as 16x16 pixel information. And record this information in bytes. One byte can store 8 bits of information, and 32 bytes can store the glyph of a Chinese character. Convert each byte to binary representation, 1 for ink, 0 for background color. 2 bytes per line, a total of 16 lines, the layout is:
1st byte, 2nd byte
, 3rd byte, 4th byte
...
31st byte, 32nd byte

This title is to give you a piece of information composed of multiple Chinese characters, each Chinese character is represented by 32 bytes, and the value of the bytes as a signed integer is given here.
The title's requirements are hidden in this information. Your task is to restore the glyphs of these Chinese characters, find out the requirements of the questions, and fill in the answers according to the requirements.
This piece of information is (10 Chinese characters in total):

4 0 4 0 4 0 4 32 -1 -16 4 32 4 32 4 32 4 32 4 32 8 32 8 32 16 34 16 34 32 30 -64 0 
16 64 16 64 34 68 127 126 66 -124 67 4 66 4 66 -124 126 100 66 36 66 4 66 4 66 4 126 4 66 40 0 16 
4 0 4 0 4 0 4 32 -1 -16 4 32 4 32 4 32 4 32 4 32 8 32 8 32 16 34 16 34 32 30 -64 0 
0 -128 64 -128 48 -128 17 8 1 -4 2 8 8 80 16 64 32 64 -32 64 32 -96 32 -96 33 16 34 8 36 14 40 4 
4 0 3 0 1 0 0 4 -1 -2 4 0 4 16 7 -8 4 16 4 16 4 16 8 16 8 16 16 16 32 -96 64 64
16 64 20 72 62 -4 73 32 5 16 1 0 63 -8 1 0 -1 -2 0 64 0 80 63 -8 8 64 4 64 1 64 0 -128
0 16 63 -8 1 0 1 0 1 0 1 4 -1 -2 1 0 1 0 1 0 1 0 1 0 1 0 1 0 5 0 2 0 
2 0 2 0 7 -16 8 32 24 64 37 -128 2 -128 12 -128 113 -4 2 8 12 16 18 32 33 -64 1 0 14 0 112 0
1 0 1 0 1 0 9 32 9 16 17 12 17 4 33 16 65 16 1 32 1 64 0 -128 1 0 2 0 12 0 112 0
0 0 0 0 7 -16 24 24 48 12 56 12 0 56 0 -32 0 -64 0 -128 0 0 0 0 1 -128 3 -64 1 -128 0 0 

Similar to vector, the bitset class is a class template; unlike vector, bitset type objects differ only in their length and not in their type. When defining a bitset, to make it clear how many bits the bitset contains, its length value must be given in angle brackets.
The function of bitset is to convert a number into binary bitset<8> is to convert a number into an 8-bit binary, so when outputting, it should be converted into string output. This should be easy to understand. Problem-
solving ideas:

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    string str1,str2;
    while(cin >> n >> m){
        bitset <8> b(n);//b有8位,转换二进制的形式 
        str1 = b.to_string();
        int len1 = str1.length();
        for(int i = 0;i < len1;i++){
         	if(str1[i] == '0'){//-八个1表示-1,-四个1加四个0 表示负16 
           		printf(" ");
         	}else{
           		printf("*");
         	} 
        }
        bitset <8> c(m);//c有8位,转换二进制的形式
        str2 = c.to_string();
        int len2 = str2.length();
        for(int i = 0; i < len2;i++){
         	if(str2[i] == '0'){
           		printf(" ");
         	}else{
           		printf("*");
         	} 
        }
        printf("\n");
    }
    return 0;
}

Problem solving idea 2:

#include<iostream>
using namespace std;
int main(){
    int m,n,w[16];
    while(cin >> m >> n){
        for(int i = 7;i >= 0;i--){
            w[i] = m&1;
            m >>= 1;
        }
        for(int i = 15;i >= 8;i--){
            w[i] = n&1;
            n >>= 1;
        }
        for(int i = 0;i <= 15;i++){
            if(w[i] != 0){
                cout << w[i] << " ";    
            }else{
                cout << " " << " ";
            }   
        }
        cout << endl;
    }
    return 0;
}

3. Product trailing zeros
The following 10 lines of data, each line has 10 integers, how many zeros are there at the end of their product?

5650 4542 3554 473 946 4114 3871 9073 90 4329 
2758 7949 6113 5659 5245 7432 3051 4434 6704 3594 
9937 1173 6866 3397 4759 7557 3070 2287 1453 9899 
1486 5722 3135 1170 4014 5510 5120 729 2880 9019 
2049 698 4582 4346 4427 646 9742 7340 1230 7683 
5693 7015 6887 7381 4172 4341 2909 2027 7355 5649 
6701 6645 1671 5978 2704 9926 295 3125 3878 6785 
2066 4247 4800 1578 6652 4616 1113 6205 3264 2915 
3966 5291 2904 1285 2193 1428 2265 8730 9436 7074 
689 5510 8243 6114 337 4096 8199 7313 3685 211 

Note: What needs to be submitted is an integer representing the number of trailing zeros. Do not fill in any superfluous content.
Center: This question turns out to be the number of 2 and 5, because 2 and 5 can only be combined to produce 0, and the final result is the smallest of 2 and 5.
Problem-solving idea 1:
java Dafa

import java.math.*;
 
public class BigNumber{
	public static void main(String[] args) {
			int num[] = {5650 ,4542 ,3554, 473 ,946, 4114 ,3871, 9073 ,90, 4329 ,
					2758 ,7949 ,6113, 5659 ,5245, 7432, 3051, 4434, 6704 ,3594, 
					9937 ,1173 ,6866 ,3397, 4759, 7557 ,3070 ,2287 ,1453, 9899 ,
					1486 ,5722 ,3135 ,1170, 4014 ,5510, 5120, 729,2880, 9019 ,
					2049 ,698, 4582, 4346, 4427, 646 ,9742 ,7340 ,1230, 7683 ,
					5693, 7015, 6887, 7381, 4172, 4341, 2909, 2027, 7355, 5649 ,
					6701, 6645, 1671, 5978 ,2704, 9926, 295, 3125, 3878, 6785 ,
					2066 ,4247, 4800 ,1578, 6652, 4616, 1113 ,6205, 3264, 2915 ,
					3966, 5291, 2904, 1285, 2193, 1428 ,2265 ,8730, 9436, 7074 ,
					689 ,5510 ,8243, 6114, 337, 4096, 8199, 7313 ,3685, 211};
			BigInteger sum,tmp;
			sum = BigInteger.valueOf(1); //初始化为1
			for(int i = 0;i < num.length;i ++){
				tmp = BigInteger.valueOf(num[i]);
				sum = sum.multiply(tmp);
			}
		System.out.println(sum);
	}
}

insert image description here
Problem- solving idea 2:
② Python implementation, I also saw other netizens say that they were implemented in python when they took the test. Sure enough, Python has no limit on the size of integers! In theory, it can store as much memory as we have. My love for Python deepens again~~~

print(5650*4542*3554*473*946*4114*3871*9073*90*4329*
2758*7949*6113*5659*5245*7432*3051*4434*6704*3594*
9937*1173*6866*3397*4759*7557*3070*2287*1453*9899*
1486*5722*3135*1170*4014*5510*5120*729*2880*9019*
2049*698*4582*4346*4427*646*9742*7340*1230*7683*
5693*7015*6887*7381*4172*4341*2909*2027*7355*5649*
6701*6645*1671*5978*2704*9926*295*3125*3878*6785*
2066*4247*4800*1578*6652*4616*1113*6205*3264*2915*
3966*5291*2904*1285*2193*1428*2265*8730*9436*7074*
689*5510*8243*6114*337*4096*8199*7313*3685*211)

insert image description here
Problem- solving idea 3:
Center: This question turns out to be the number of 2 and 5, because 2 and 5 can only be combined to produce 0, and the final result is the smallest of 2 and 5.
①Programming to solve this problem:

#include<iostream>
using namespace std;
int main(){
    int sum1=0,sum2=0,sum;
    int n;
    for(int i = 0;i < 100;i++){
        cin >> n;
        while(n % 5 == 0){
            sum1++; 
            n =n / 5; 
        }
        while(n%2 == 0){
            sum2++;
            n = n / 2;
        }
    }
    sum = min(sum1,sum2);//取最小值
    cout << sum << endl;
    return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325679957&siteId=291194637