#P9239. [蓝桥杯 2023 省 B] 填空问题

[蓝桥杯 2023 省 B] 填空问题

Problem Description

Task A: Date Counting

Problem Description

Xiao Lan now has an array of length 100100, where each element is a digit from 00 to 99. The elements of the array from left to right are as follows:

5 6 8 6 9 1 6 1 2 4 9 1 9 8 2 3 6 4 7 7 5 9 5 0 3 8 7 5 8 1 5 8 6 1 8 3 0 3 7 9 2 7 0 5 8 8 5 7 0 9 9 1 9 4 4 6 8 6 3 3 8 5 1 6 3 4 6 7 0 7 8 2 7 6 8 9 5 6 5 6 1 4 0 1 0 0 9 4 8 0 9 1 2 8 5 0 2 5 3 3

Now he wants to find some subsequences in this array that satisfy the following conditions:

  1. The subsequence has length 88.

  2. Following the index order, this subsequence can form a date in yyyymmdd format, and this date must be a day in the year 2023, for example 2023090220230902, 2023122320231223. Here yyyy is the year, mm is the month, and dd is the day. If the month or day has only one digit, it must be padded with a leading zero.

Please help Xiao Lan compute how many distinct dates in 2023 can be found under the conditions above. The same date should be counted only once.

Answer Submission

This is a fill-in-the-blank (result-only) problem. You only need to compute the result and submit it. The result is an integer. When submitting, write only this integer; any extra content will cause you to get no score.

Task B: Entropy of a 01 String

Problem Description

For a 01 string S=x1x2x3xnS=x_{1} x_{2} x_{3} \ldots x_{n} of length nn, the Shannon information entropy is defined as $H(S)=-\sum_{i=1}^{n} p\left(x_{i}\right) \log_{2}\left(p\left(x_{i}\right)\right)$, where p(0),p(1)p(0),p(1) are the proportions of 0s and 1s in this 01 string.

For example, for S=100S=100, the entropy is $H(S)=-\frac{1}{3}\log _{2}\left(\frac{1}{3}\right)-\frac{2}{3} \log _{2}\left(\frac{2}{3}\right)-\frac{2}{3} \log _{2}\left(\frac{2}{3}\right)=1.3083$. For a 01 string of length 2333333323333333, if its entropy is 11625907.579811625907.5798, and the number of 0s is less than the number of 1s, then how many times does 0 appear in this 01 string?

Answer Submission

This is a fill-in-the-blank (result-only) problem. You only need to compute the result and submit it. The result is an integer. When submitting, write only this integer; any extra content will cause you to get no score.

Input Format

The input is a single uppercase letter indicating which task it is.

Output Format

Output the answer corresponding to the given task letter.

Hint

Answer template for reference.

#include<iostream>
using namespace std;
int main() {
    string ans [] = {
        "The answer of task A", // Replace the content in double quotes with the answer for task A.
        "The answer of task B", // Replace the content in double quotes with the answer for task B.
    };
    char T;
    cin >> T;
    cout << ans[T - 'A'] << endl;
    return 0;
}

Translated by ChatGPT 5