The 13th Blue Bridge Cup Software Competition Provincial Competition (C/C++ University Group C)

Blue Bridge Cup 2022 Provincial Competition Zhenti
C/C++ University Group C


  Persimmons should be picked softly, and where they are written.


Question A: Arrange Letters

Total score for this question: 5 55 points


【Problem Description】

  Little Blue wants to arrange the letters in a string according to their order in the alphabet.

  For example, LANQIAO \mathrm{LANQIAO}L A N Q I A O isAAILNOQ \mathrm{AAILNOQ}A A I L N O Q。 _

  又如, G O O D G O O D S T U D Y D A Y D A Y U P \mathrm{GOODGOODSTUDYDAYDAYUP} G O O D G O O D S T U D Y D A Y D A Y U P isAADDDDDGGOOOOPSTUUYYY \mathrm{AADDDDDGGOOOOPSTUUYYY}A A D D D D D G G O O O O P S T U U Y Y。_ _

  For the following strings, what is the string after permutation?

  W H E R E T H E R E I S A W I L L T H E R E I S A W A Y \mathrm{WHERETHEREISAWILLTHEREISAWAY}WHERETHEREISAWILLTHEREISAWAY

【Answer submission】

  This is a fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is a string consisting of uppercase letters. Only fill in this string when submitting the answer. Fill in the extra content will not be able to score.


AAAEEEEEEHHHIIILLRRRSSTTWWWY


#include <stdio.h>

char *str = "WHERETHEREISAWILLTHEREISAWAY";

int total[128];

int main() {
    
    
    while (*str) ++total[*str++];
    for (char i = 'A'; i <= 'Z'; ++i)
        while (total[i]--) putchar(i);
}

  The pointer flies around and it's over.


Question B: Special Hours

Total score for this question: 5 55 points


【Problem Description】

  2022 20222 0 2 2 years2 2Feb 22222 2 days22 2222: 20 20 2 0 is a meaningful time, the year is2022 20222 0 2 2 by3 33 222 and1 11 000 , if the month and day are written as4 44 digits, for0222 02220 2 2 2 , also by3 33 222 and1 11 000 , if the hour and minute in the time are written as4 44 bits, or by3 33 222 and1 11 000 composition.

  Xiaolan is very interested in such times, he also found other similar examples, such as 111 1111 1 1 Year10 1010 11 111 1 day01 0101: 11 11 11 2202 2202 2 2 0 2 22Feb 22222 2 days22 2222: 02 02 0 2 and so on.

  Excuse me, how many times are there in this year written as 4 44 digits, month and day written as4 44 bits, time is written as4 44 digits after 3 by33 one-of-a-kind numbers and1 11 composed of another number. Attention1111 11111 1 1 1 Year11 111 November 11 111 1 day11 1111: 11 11 1 1 doesn't count because it doesn't have two numbers in it.

【Answer submission】

  This is a fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer. Fill in the extra content will not be able to score.


212


  in 3 3Insert 1 1 into 3 identical single digits1 single digit, obviously can form4 44 different numbers (not necessarily4 44 digits), so we can have another valid month, day, hour and minute with4 44 different years form a mapping relationship, as long as the legal number of days, months, hours and minutes is counted, multiply it by a4 44 , the answer is calculated.

#include <stdio.h>

int buff[10], ans = 0;

int days[]{
    
    0, 31, 29, 31, 30 ,31, 30, 31, 31, 30 ,31, 30, 31};

int main() {
    
    
    for (int MM = 1; MM <= 12; ++MM)
        for (int dd = 1; dd <= days[MM]; ++dd)
            for (int HH = 0; HH < 24; ++HH)
                for (int mm = 0; mm < 60; ++mm) {
    
    
                    for (int i = 0; i < 10; ++i) buff[i] = 0;
                    ++buff[MM / 10]; ++buff[MM % 10];
                    ++buff[dd / 10]; ++buff[dd % 10];
                    bool flag1 = 1, flag2 = 1;
                    for (int i = 0; i < 10; ++i)
                        if (buff[i] == 3) flag1 = 0;
                        else if (buff[i] == 1) flag2 = 0;
                    if (flag1 || flag2) continue;
                    --buff[HH / 10]; --buff[HH % 10];
                    --buff[mm / 10]; --buff[mm % 10];
                    for (int i = 0; i < 10; ++i)
                        if (buff[i] != 0) flag1 = 1;
                    if (!flag1) ++ans;
                }
    printf("%d", ans << 2);
}

Let's write group A first

Guess you like

Origin blog.csdn.net/qq_43449564/article/details/124136808