CSDN programming competition forty-one solution

Competition overview

CSDN Programming Competition Forty-One: Competition Details (csdn.net)

The question type of this competition is different from the previous ones, and there are some choices, judgments, and fill-in-the-blank questions. However, there are also many places to complain:

1. The score setting of programming questions is unreasonable. There are only two questions, the first question is 20 points, the second question is 55 points, and this 55-point question has only 3 test points, and the amount of test data is too small.

2. Although the test time has been increased to five hours, it is actually not very meaningful, because the objective questions can be completed in a few minutes, which means that the two programming questions are given four hours, and two hours for the previous four questions are enough Four hours is obviously too much when it's done. And at night, I couldn't move the volume. In fact, not many people actually spent five hours answering the questions.

3. The second programming question needs to refer to a lot of materials to make it, but it will be forced to submit as long as the page is switched to a certain number of times. It is recommended to put all the content required by the topic (background, description, relevant picture materials, etc.) in the topic description section. If it really cannot be displayed, it can be made into an internal pop-up window or multi-tab form, so that there is no need to jump out of the page.

There are still many things to complain about. In short, the user experience this time is not very good. I hope that Station C can continue to optimize this aspect and do better and better.

competition solution

Topic 1. Number system conversion

Since humans have ten fingers, the most commonly used number system for human counting is the decimal system. However, the most commonly used base in computers is binary, because binary can be represented by relatively few physical states. However, there are only two numbers of 0 and 1 in binary, and it is easy to write very long, so octal or hexadecimal is often used. Octal numbers are represented by eight digits from 0 to 7, and each octal enters one. In addition to the ten numbers from 0 to 9, hexadecimal numbers also use six letters from A to F (A to F represent 10 to 15 in decimal), a total of sixteen symbols to represent, every hexadecimal one. Please convert the entered number to decimal. If there are only 0s and 1s in the number, then it is considered binary. If there are only 0 to 7 in the number, then it is considered octal. If there are more than 0 to 7 in the number, then it is considered hexadecimal. If there is a letter other than 0 to 9, A to F (case-insensitive), then please output "NaN".

There are two steps to solving this problem:

1. Determine the type of characters contained in the input data, and obtain the base type.

2. According to the base type, convert the input data corresponding to the base system into a decimal value.

This question is not difficult, it is considered as the sign-in question of this competition.

Topic 2. Abacus instruction generator

It is very simple for modern people to do the addition and subtraction of two numbers: just press the first number on the calculator, then press the "+" or "-" key, and then press the second number, Finally, press the "=" key to see the result of the operation. But ancient people did not have calculators. Fortunately, ancient China had such a tool as abacus. Classmate zjg555543 of CSDN gave the table of formulas used in abacus addition and subtraction in his blog: table of formulas for abacus mental arithmetic . Please try to generate the corresponding abacus calculation instruction sequence based on the addition and subtraction of the input numbers. Each instruction corresponds to one or several sentences of formulas, and output the position where it is applied and the number of times the formula involves. The ones place is recorded as position 0, the tens place is recorded as position 1, the hundreds place is recorded as position 2, and so on. Likewise, the tenths place is recorded as position -1, the hundredths place is recorded as position -2, and so on. Some formulas only need to move the upper or lower bead once, such as "one up one" and "five down five". Others need to dial the upper bead once and the lower bead once, such as "six up six", "nine down nine", "three down five to two" and "eight back one back five to three" ("into one" or "Back one" is to advance one or retreat one from the adjacent high position, and it is not necessary to actually dial the beads when the position executes this formula), etc. Finally, output the total number of bead dials.

The description of this topic is too complicated, and too many page switches will be forced to submit, so it is really impossible to start.

Guess you like

Origin blog.csdn.net/x1051496412/article/details/129886198