Python programming solution to a problem [Blue Bridge Cup official website] DAY1- exam environment introduction and induction training

  1. Group

The competition is intended, regardless of category.

All graduate students, undergraduate focus, general undergraduate and vocational colleges are invited to the group, unified awards.

  1. Competition Schedule

National Auditions Duration: 4 hours.

Finals Duration: 4 hours.

Detailed schedule information to the organizing committee announced prevail.

  1. Competition Form

Individual competition, one person, one machine, the entire computer-based test.

Players machines connected to the server over the LAN arena of competition.

Players answer process can not access the Internet, do not allow the use of resources than the unit (such as a USB connection).

Competition system to "Server - Browser" payments of questions, the answers to recycle players.

  1. Contestants machine environment

Players machine configuration:

X86-compatible machines, the memory is not less than 4G, not less than 60G hard disk

Operating System: Windows7 and above

Programming environment:

Compiler: Python 3.6.5

Editor: IDLE (Python comes editor)

  1. Examination form

Contest entitled completely objective questions.

According to survey results submitted answers to the player scoring basis.

There are two kinds of questions.

5.1. The results fill in the blank

Title Description solution having a problem is determined. Solution requires players to fill in the blank questions.

It does not require problem solving process, problem-solving means no limit (you can use any development language or tool, or even a manual calculation) is only required to fill out the final result.

The final solution is a string or an integer, the final solution can be expressed using ASCII characters.

5.2. Programming big problem

Subject contains an explicit description of the problem, the input and output formats, sample data, and for explaining the problem.

Programming issues big issue involved must have a clear objective criteria to judge the results are correct, and can be judged by the results of the program.

Players should be based problem description, write program (written in Python) to solve the problem, in the evaluation process should player reads data from the standard input, and outputs a final result to the standard output.

In the description of the problem will be explicitly given the conditions and restrictions, issue a clear mandate, the players of the program should be able to solve all possible under the given conditions and restrictions.

Players procedures should be universal, not only applicable to the sample data subject.

To test the performance of the players given the solution, with the score when the test case may contain a large amount of data Pressure test cases, to consider the feasibility and efficiency of the players as possible selection algorithm.

  1. Test questions range

Questions test players ability to solve practical problems, the results fill-in, players can use hand calculations, software, and programming solutions for large programming problem, players can only be programmed to solve.

Competition focuses on test players ability to utilize algorithms and data structures, many questions need to use computer algorithms to effectively addressed.

Test include:

Python programming foundation: Includes the ability to use Python to write programs. This section does not test players' understanding of a grammar, players can use their favorite programming statements.

Computer algorithms: enumeration, sorting, searching, counting, greedy, dynamic programming, graph theory, number theory, game theory, probability theory, computational geometry, string algorithms.

Data structures: arrays, objects / structures, string, queue, stack, tree, FIG heap, balanced tree / tree line, complex data structures, nested data structure.

  1. The answer submitted

The answer content players only submitted within the game time can be used to review any submitted are invalid after the game.

Players should use the specified test page to submit the code, submit any other means (such as mail, U disk) not as a basis for evaluation.

Players can view the game at any time before the submission of its own codes, you can re-submit the answer to any subject, for each questions, only the last one is saved and submitted as a basis for evaluation. During the competition, the results of the evaluation will not be displayed to the player, the player should design their own data to debug your program without feedback.

For each of the questions, the players should answer the questions to be submitted to copy and paste content on the page.

Python programs can only use Python comes with a library, do not install other extensions during evaluation.

Procedures should contain only calculation module, do not include any other modules, such as graphics, system call interfaces, such as system outages. For a system call interface should be carried out by the standard library.

Libraries referenced in the program source code should be written in a way in the program, should be submitted in the time of filing and other parts of the program.

  1. score

All use the automatic scoring machine.

For the results of fill-in, subject to ensure that there is only one solution, the result was exactly the same as reconciliation players only score no points appear malformed or superfluous contents.

For large programming problem, the evaluation system will use multiple evaluation data to test the program. Each has a corresponding data evaluation scores. Submitted player program will run as an input respectively for each evaluation data. For an evaluation of the data, if the output of the program and the correct answer is the players match, the players receive points that evaluation data.

Evaluation data evaluation questions generally used in a given sample input and output are not the same. It is recommended that players use different data to test their programs before submitting program.

Procedures should be strictly in accordance with the requirements submitted by the output format to output, including the output requirements spaces and line breaks. If the program does not follow the requirements of the output format is determined to be the answer wrong. Please note that the program in the output of multiple output content also belongs not follow the required output format, so when output Do not output any extra content, such as debugging output.

  1. Sample Questions

1 Sample questions: a rectangular cut (fill in the blank results)

【Problem Description】

Xiao Ming has a number of rectangular material, from which he cut out some of the material rectangle square.

When he faced a rectangular piece of material, he always cut from the middle knife, cut out a piece of the largest squares, leaving a rectangle, then cut the rest of the rectangular material until all cut up into squares.

For example, a material for both sides were 3 and 5 (referred to as 5 × 3), Bob will successively cut 3 × 3,2 × 2,1 × 1,1 × 1 4 squares.

Now Bob has a rectangular material, the long sides 324 and 2019, respectively. Will Xiao Ming will eventually cut the number of squares?

[Answer] submitted

This is a result of fill in the blank questions, you only need to submit to the calculated result. The results of this question is an integer, when submitting answers only to fill in the integer, fill in the extra content will not score.

Note: The above description is part of the problem, you can directly hand count when the players do question the answer to that step by step in accordance with the meaning of the title cut, and finally get the number of rectangular cut-out, hand calculations may take some time. If a player other ways to speed up the use of division in the hand count, the time may be less. If you write a program to calculate the player can reduce errors occurring in the hand count.

The answer to this question: 21

Sample Question 2: special number and a (large programming problem)

【Problem Description】

Xiaoming contain digital 2,0,1,9 digit of interest in it (not including the leading 0), 1 to 40 in such numbers 32, 39 and 40 to include 1,2,9,10, a total of 28 , and they are 574.

Will the 1 to n, all such numbers and how much?

[Input Format]

Input row contains an integer n.

[Output format]

An output line, comprising an integer, and represents a number satisfying the condition.

[Sample input]

40

[Sample output]

574

[Evaluation] Examples scale and agreed with

20% to Reviews embodiment, 1≤n≤10 use.

For 50% Reviews embodiment, 1≤n≤100 use.

For 80% Reviews embodiment, 1≤n≤1000 use.

For reviews all cases, 1≤n≤10000 use.

Description: This title is a programming problem, players need to write a program to solve the problem. The following gives a reference program, written by other players as long as the program can give correct results can score.

n = int(input())

ans = 0

for i in range(1,n+1):

    t = i

    ok = False

    while t>0:

        g = t % 10

        if g==2 or g==0 or g==1 or g==9:

            ok = True

        t = t // 10

    if ok:

        ans += i

print(ans)
  1. Other Considerations

(1) Players must be eligible to participate, not fraud. Once the qualification problem is found, cancel its qualifications; found during the race issue, cancel the qualifying competition; found the problem after the competition, cancel the competition results, to recover the award certificates and prizes and publicity in the contest official website.

(2) Participants must comply with competition rules, to comply with court discipline, obey the command of the Organizing Committee and arrangements for care of the playing field equipment.

(3) Competition + using a small amount of artificial machine scoring. Players need to pay special attention to form to submit answers. Must read the questions carefully input, output requirements, and example, not arbitrarily add unwanted content.

(4) the player must use the default editor default encoding format, use another editor responsible for problems caused by the players themselves.

Getting questions training Fibonacci series

Resource limitation
time limit: 1.0s memory limit: 256.0MB
problems described
recursion formulas for the Fibonacci sequence: Fn = Fn-1 + Fn -2, where F1 = F2 = 1.

When n is relatively large, Fn is very great, and now we want to know, Fn is divided by the number 10007 is.

Input format
input contains an integer n.
Output format
output one line containing an integer representing the Fn remainder of the division of 10007.
Description: In this problem, the answer is to require Fn is divided by 10007, so we can figure this out as long as the remainder can be, without the need to calculate the exact value of Fn, then the result is calculated by dividing the number 10007 to take over direct calculation the remainder often than first calculate the original number and then take the remainder simple.

样例输入
10
样例输出
55
样例输入
22
样例输出
7704

The data size and Conventions
1 <= n <= 1,000,000.

x=eval(input())
a=1
b=1
for i in range(x-1):
    a,b=b%10007,(a+b)%10007
print(a)

PS: less than 10007 after a few take the remainder of its own
entry area of a circle training questions

Resource limitation
time limit: 1.0s memory limit: 256.0MB
problem description
to a circle of a given radius r, of circular area.
Input format
input contains an integer r, represents the radius of the circle.
Output format
output line, comprising a real number, rounded to 7 after the decimal point indicates the area of a circle.
Description: In this problem, the input is an integer, but the output is a real number.

For the problem of real output, be sure to look at the requirements of real output, such as required in this question after seven decimal places, then your program must be strictly output seven decimal places, too much or too little output of decimal places are not , it will be considered an error.

The real question is if the output is not specified, rounding is performed by rounding.

Input Sample
4
Sample Output
50.2654825
data size and Conventions
1 <= r <= 10000.
Prompt
this question of high precision, please note that the value of π should take a more accurate value. You can use constants to represent π, for example PI = 3.14159265358979323, mathematical formulas may be used to seek π, such as PI = atan (1.0) * 4 .

r=eval(input())
print("{:.7f}".format(3.14159265358979323*r*r))

Started training sequence summed questions

Resource limitation
time limit: 1.0s memory limit: 256.0MB
Problem Description
evaluated 1 + 2 + 3 + ... + n is.
Input format
input comprises an integer n.
Output format
output line, including an integer representing the value 1 + 2 + 3 + ... + n is.
Sample Input
4
Sample output
10
Sample input
100
Description: There are some sample questions will give multiple sets of input and output to help you do a better title.

General prior to the submission of all these samples are to be tested by the job, but that does not mean that these set of sample data are correct your program is entirely correct potential errors may still lead to lower your score.

Sample output
5050
data size and Conventions
1 <= n <= 1,000,000,000.
Note: Please note that the size of the data here.

The idea is to direct this question directly use a loop to accumulate, however, when the method is large-scale data, this "violence" often leads to a timeout. At this point you need to think of other methods. You can try, if you use 1 billion as the input your program, your program is not able to run out within the time stipulated in the above provisions.

Another problem for noteworthy that this place is the size of the answer is not in your default language of integer (int) in the range, if you use an integer to hold the result, the result will lead to error.

If you are using C or C ++ language and are ready to use printf output, then your format string should be written% I64d to output a long long integer types.

n=eval(input())
print("{:.0f}".format(n*(n+1)/2))
python support large numbers of operational characteristics, a lot easier than c players, but the most annoying is that, with the same players c python3.6 environment, people can also be used. wtf

Questions induction training A + B problem

Resource limitation
time limit: 1.0s memory limit: 256.0MB
Problem Description
input A, B, output A + B.
Description: In the "Problem Description" This section gives the meaning of the questions, as well as the required target.
Input format
of the first row comprises two input integers, separated by a space, respectively, A, B.
Description: "input format" is described in the test of your program, given certain inputs meet format.

When do question you should assume that given a certain input is to meet the requirements of the input format, so you do not need to be checked on the input format. Check the format of the excess could backfire, use your bugs.

During the test, the system will automatically input data into your program, you can not give any hints. For example, when you are prompted to enter the "Enter A, B" kind of thing is not needed, this excess output will make your program is judged as an error.

Output format
output line, including an integer representing the value of A + B.
Description: "Output format" is required when your program must meet the output format.

On output, your program must meet the requirements of formats, can not be anything less, nor more than anything. If your output format and content requirements are not the same, your application will be judged as an error, a message including your output, intermediate debugging information, statistical information on the timing or the like.

Sample input
1245
Description: "Sample Input" shows an example of an input group satisfies the "input format" requirement.

Enter here given only one input may be used to test your program, at the time of the test, there will be more input to test your program.

Sample output
57
Description: "sample output" shows an example of an output set meet "output format" claims.

Results are output sample and the corresponding sample is input, therefore, you can simply check your program using the input and output sample.

To be pointed out that, to input and output through the sample program is not necessarily the correct procedures at the time of testing, testing is performed with a lot of sets of data, but not limited to sample data. There may be a program by the sample data, but when the test was still only 0, probably because this program only in special cases correct some similar examples in rather versatile, there will be more data when re-tested error.

For example, for this question, if you write a program regardless of the input what are the input 57, the sample data is correct, but test other data, even if the input is 1 and 2, this program can also output 57, then for the other data this program are incorrect.

Agreed with the data size
-10000 <= A, B <= 10000.
Description: "Data size and agreement" given the scope of the questions in the main parameters.

This range is very important for problem-solving, different data ranges will lead to questions require a different solution to solve. To the question in the present example A, not B range by using integer (int) to store, if larger, than int range, will have to consider other methods to save large numbers.

There are some range at a convenient time in the "Problem description" directly to, so when problems do not only look at this range, but also pay attention to the problem described.

Tip
The title C ++ source code is as follows:

#include

using namespace std;

main int ()
{
int A, B;
CIN >> A >> B;
COUT << A + B;
return 0;
}
The title C source code is as follows:

#include <stdio.h>

int main ()
{
int A, B;
Scanf ( "% D% D", & A, & B);
the printf ( "% D", A + B);
return 0;
}
the Java source code for this problem is as follows:

import java.util. *;

the Main class public
{
public static void main (String args [])
{
Scanner Scanner new new SC = (the System.in);
Integer sc.nextInt A = ();
Integer sc.nextInt B = ();
System.out.println ( b + a);
}
}
Note: to answer, please click on the top of the page "submit this question" button, the page will jump to the page to submit the code, compile choosing your language, your paste to write good code code box, then click the "submit answers" button.

Your answers submitted to the system after the system will automatically be sentenced to divide your code and jump to the list of results inside, you can see the status of your submission code directly from the list, generally after a few seconds, you can see the results sentenced to score.

The title as the first question, are already in the prompt to C ++ and Java code, you can copy the code directly to the past as their code delivery.

Please pay special attention to, Java main class name must be Main.

txt=input()
a,b=txt.split(" ")
print(int(a)+int(b))
发布了545 篇原创文章 · 获赞 129 · 访问量 4万+

Guess you like

Origin blog.csdn.net/weixin_43838785/article/details/104185844