Fifth annual Blue Bridge Cup National Software Design competition--2013 year in-school trials Java topic

Source: Internet
Author: User
Tags gcd ming

Fifth annual Blue Bridge Cup national Software Design competition

- Annual in-School Tryouts Java Topic

First, the candidates note:

(1) "Results in the blanks" requires contestants to fill in the results directly according to the title description. The solution is unlimited. Do not seek source code.

Put the answer in the "Candidates folder" corresponding to the title of the file can be.

(2) "Code Blanks" requires contestants to fill in the missing part based on figuring out how the given code works, making the program logic correct and complete. The code is filled in no more than one statement (that is, the semicolon cannot appear in the middle).

Fill in the blanks with the answer (only the answer in the blanks, excluding the existing code) in the "Candidates folder" corresponding to the title of the file can be.

(3) "Programming problem" requires the player to design a program for the given input can give the correct output results. A candidate's program only has the chance to score when it can run the correct results. Note: The input data used in the grading may be different from the instance data given in the quiz paper. The player's program must be generic and not only valid for the data given in the quiz.

For each programming topic, candidates are required to write all the methods in a file. After debugging, deposit with the "Candidate folder" in the corresponding title of the file can be. The relevant engineering documents should not be copied into.

Second, Operation preparation:

(1) in the "2013Java School audition file" under the establishment of "candidate folder", the name of "Student + name", for example, your name is: Li Ming, school number is 2012999001, then your "Candidate folder" is: 2012999001 Li Ming.

(2) Move all text files under "2013Java in-school tryouts" to your candidates folder.

Third, the test content:

1."results in the blanks" (5 points)

Problem Description:

The National Day of 1949 (October 1) is Saturday. The National Day of the Year (2013) is Tuesday.

Then, from the founding of the present, there are 10 national day is just Monday. What are the years, respectively? Ask to write down which years, each year as a line.

As long as the answer, unlimited means! You can use Windows Calendar, Windows Calculator and other tools. Of course, you can also program! No need to submit source code!

Put the answer in the file t1.txt.

2. "results in the blanks" (5 points)

Problem Description:

625 This number is very special, 625 squared equals 390625, just the last 3 bits are 625 itself. Besides 625, are there any other 3-digit numbers with this feature?

Please look for all such 2 digits and 3 digits: The last 2 bits of the square of 2 digits are the number itself, and the last 3 bits of the square of the 3-digit number are the number itself.

The output is output in the following format, requiring small to large and one row for each number found. For example, find the 625 output as:

625*626=390625

As long as the answer, unlimited means! Of course, you can also program! No need to submit source code!

Put the answer in the file t2.txt.

3."Code Blanks" (5 points)

description of the problem: three sort

The general sort has many classical algorithms, such as fast sorting, hill sorting, and so on.

But in practical applications, there are often more or less special requirements. We do not need to apply those classical algorithms, can be based on the actual situation to establish a better solution.

For example, sorting the numbers in an integer array:

So that negative numbers are on the left side, positive numbers are on the right, 0 in the middle. Note that the problem is characterized by the negative and positive areas not requiring order. You can use this feature to end the battle with 1 linear scans!!

The following procedure achieves this goal.

static void sort (int[] x)

{

int p = 0;

int left = 0;

int right = X.length-1;

while (P<=right) {

if (x[p]<0) {

int t = X[left];

X[left] = x[p];

X[p] = t;

left++;

p++;

}

else if (x[p]>0) {

int t = X[right];

X[right] = x[p];

X[p] = t;

right--;

}

else{

_________________________; Code fill-in position

}

}

}

If the given array:

25,18,-2,0,16,-5,33,21,0,19,-16,25,-3,0

Then the following are sorted:

-3,-2,-16,-5,0,0,0,21,19,33,25,16,18,25

Please analyze the code logic and infer the code at the line, and put the answer in the file t3.txt.

Note: Only the missing code as an answer, do not fill in the extra code, symbols or descriptive text!!

4."Code Blanks" (5 points)

problem Description: rational number class

A rational number is a number that can be represented as a ratio of two integers. In general, we use approximate decimal notation. However, there are times when errors are not allowed and two integers must be used to represent a rational number.

At this point, we can create a "rational number class", the following code initially achieved this goal. To be concise, it provides only addition and multiplication operations.

Class Rational

{

Private long RA;

Private long RB;

Private long gcd (long A, long B) {

if (b==0) return A;

return gcd (B,A%B);

}

Public Rational (Long A, long B) {

RA = A;

RB = b;

Long k = gcd (RA,RB);

if (k>1) {//requires numerator

RA/= k;

RB/= K;

}

}

Addition

Public rational Add (rational x) {

return ________________________________________; Fill in the blanks

}

Multiplication

Public Rational Mul (rational x) {

return new Rational (Ra*x.ra, RB*X.RB);

}

Public String toString () {

if (rb==1) return "" + ra;

Return RA + "/" + RB;

}

}

Examples of using this class:

Rational a = new rational (1,3);

Rational B = new Rational (1,6);

Rational C = A.add (b);

System.out.println (A + "+" + B + "=" + C);

Please analyze the code logic and infer the code at the line, and put the answer in the file t4.txt.

Note: Only the missing code as an answer, do not fill in the extra code, symbols or descriptive text!!

5. Problem Description (20 points)

The recursive formula for the Fibonacci sequence is: Fn=fn-1+fn-2, wherein f1=f2=1.

When n is large, FN is also very large, and now we want to know what the remainder of FN divided by 1000 is. Please write a program implementation.

Input format

Enter an integer n.

Output format

The output line contains an integer that represents the remainder of FN divided by 1000.

( Note that no extra input and output hints are necessary)

Sample input

Sample input

Sample input

Sample input

10

22

100

10000

Sample output

Sample output

Sample output

Sample output

55

711

75

875

Data size and Conventions: 1 <= n <= 10000.

Put the answer in the file t5.txt.

6. Problem Description (20 points)

Consider the equation: a^3 + b^3 = c^3 + d^3

Where: "^" indicates a exponentiation. A, B, C, D are non-identical positive integers less than 30.

There are many solutions to this equation. Like what:

A = 1,b=12,c=9,d=10 is a solution. because: 1 cubic plus 12 cubic is equal to 1729, and 9 cubic plus 10 cubic is equal to 1729.

Of course, a=12,b=1,c=9,d=10 is obviously a solution.

This is the same solution if the ABCD Exchange order is not counted.

Write a program that implements the following tasks: Find all the different positive integer solutions less than 30. The A B C D is arranged from small to large, separated by commas, and each solution occupies 1 rows. For example, just the output of the solution is:

1,9,10,12

The order of the different solutions can not be considered.

Put the answer in the file t6.txt.

7. Problem Description (20 points)

123321 is a very special number, it reads from the left and reads from the right is the same.

Enter a positive integer n, programming all such five-bit and six-bit decimal numbers to satisfy the sum of the numbers equal to N.

Input format

Enter a row that contains a positive integer n.

Output format

An integer that satisfies the condition is output in order from small to large, with each integer occupying one row.

Sample input

Sample input

52

50

Sample output

Sample output

899998

989989

998899

799997

889988

898898

979979

988889

997799

Data size and conventions: 1<=n<=54.

Put the answer in the file t7.txt.

8. Problem Description (20 points)

Please write a method void fun (int m, int k, int xx[]), the function of this method is: a greater than an integer m and immediately close to M K prime number in the array xx is returned.

For example, if you enter 17, 5, you should output: 19, 23, 29, 31, 37.

Put the answer in the file t8.txt.

Fifth annual Blue Bridge Cup National Software Design competition--2013 year in-school trials Java topic

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.