The 6th Java Group B Blue Bridge Cup Provincial Competition in 2015

Here is the topic column of the Blue Bridge Cup over the years. It will be updated successively and the real questions and answers of previous years will be released. I welcome you to follow me. Your likes and attention are the best motivation for me! ! !
The real questions are updated every day, so stay tuned

Blue Bridge Cup real questions and detailed answers over the years


Question 1: Area of ​​a Triangle

The title description
is shown in Figure 1. All small squares in the figure have area 1.
So, what should be the area of ​​the triangle in the picture?
Please fill in the area of ​​the triangle. Do not fill in any superfluous or descriptive text.
insert image description here

topic analysis
topic code



Question 2: The cube becomes itself

Topic Description
Observe the following phenomenon, the cube of a certain number, the bitwise accumulation is still equal to itself.
1^3 = 1
8^3 = 512 5+1+2=8
17^3 = 4913 4+9+1+3=17

Please count the total number of positive integers including 1, 8, and 17 that conform to this property?

Please fill in the number without any superfluous or descriptive text.
topic analysis
topic code



Question 3: Sanyang Xianrui

Problem Description
Observe the following addition algorithm:

      Xiangruishenghui
  + Sanyang Xianrui
-------------------
   Sanyang is auspicious

(If there is an alignment problem, please refer to [Figure 1.jpg])

Among them, the same Chinese characters represent the same numbers, and different Chinese characters represent different numbers.

Please fill in the 4-digit number represented by "Sanyang Xianrui" (the answer is unique), and do not fill in any redundant content.
topic analysis
topic code



Question 4: Cycle Section Length

Topic description
When dividing two integers, sometimes a recurring decimal is generated. The recurring part is called: recurring section.
For example, 11/13=6=>0.846153846153… The loop section is [846153] with a total of 6 bits. The following method can find the length of the loop section.
Please read the code carefully and fill in the missing code in the underlined part.

    public static int f(int n, int m)
    {
    
    
        n = n % m;    
        Vector v = new Vector();
        
        for(;;)
        {
    
    
            v.add(n);
            n *= 10;
            n = n % m;
            if(n==0) return 0;
            if(v.indexOf(n)>=0)  _________________________________ ;  //填空
        }
    }

topic analysis
topic code



Question 5: Nine Array Fractions

Question Description
1,2,3...9 These nine numbers form a fraction, and its value is exactly 1/3. How to make it up?

The following program implements this function, please fill in the missing code in the underlined part.

public class A
{
    
    
    public static void test(int[] x)
    {
    
    
        int a = x[0]*1000 + x[1]*100 + x[2]*10 + x[3];
        int b = x[4]*10000 + x[5]*1000 + x[6]*100 + x[7]*10 + x[8];        
        if(a*3==b) System.out.println(a + " " + b);
    }
    
    public static void f(int[] x, int k)
    {
    
    
        if(k>=x.length){
    
    
            test(x);
            return;
        }
        
        for(int i=k; i<x.length; i++){
    
    
            {
    
    int t=x[k]; x[k]=x[i]; x[i]=t;}
            f(x,k+1);
            _______________________________________       // 填空
        }
    }
    
    public static void main(String[] args)
    {
    
    
        int[] x = {
    
    1,2,3,4,5,6,7,8,9};        
        f(x,0);
    }
}

topic analysis
topic code



Question 6: Addition to Multiplication

Problem Description
We all know: 1+2+3+ … + 49 = 1225
Now you are asked to turn two of the non-adjacent plus signs into multiplication signs so that the result is 2015

For example:
1+2+3+…+10 11+12+…+27 28+29+…+49 = 2015
is the answer that meets the requirements.

Please look for another possible answer and submit the number to the left of the first multiplication sign (for the example, submit 10).

Note: What you need to submit is an integer, do not fill in any redundant content.
topic analysis
topic code



Question 7: Number of Card Types

Title description
Xiao Ming was hijacked to X Casino and forced to play cards with 3 other people.
A deck of playing cards (excluding the big and small trump cards, a total of 52 cards) is evenly distributed to 4 people, each with 13 cards.
At this time, a question suddenly popped up in Xiao Ming's mind:
If you don't consider the suit, only the point, and the sequence of the cards you get, how many initial card combinations can you get in your hand?

Please fill in the whole number without any superfluous content or explanatory text.
topic analysis
topic code



Question 8: Beverage redemption

Title description
Leyangyang Beverage Factory is holding a promotional event. Leyangyang C-type drink, with 3 bottle caps, you can change another bottle of C-type drink, and it can be circulated all the time, but credit is not allowed.

Please calculate, if Xiao Ming does not waste bottle caps and participates in activities as much as possible, then, for the n bottles of drinks he initially bought, how many drinks he can get in total in the end.

Input: an integer n, indicating the number of drinks to start buying (0<n<10000)
Output: an integer, indicating the number of drinks actually obtained

For example:
user input:
100
program should output:
149

User input:
101
Program should output:
151

Resource convention:
peak memory consumption (including virtual machine) < 256M
CPU consumption < 1000ms
topic analysis
topic code



Question 9: Base the dice

Title description
The gambling saint atm was obsessed with stacking dice in his later years, that is, stacking the dice one on top of the other.
After a long period of observation, atm discovered the mystery of stable dice: some numbers face each other repel each other!
Let's standardize the dice first: the opposite of a 1 is a 4, the opposite of a 2 is a 5, and the opposite of a 3 is a 6.
Assuming that there are m groups of mutually exclusive phenomena, the faces of the two numbers in each group are close to each other, and the dice cannot be stably stacked. atm wants to count how many different possible ways to roll the dice.
The two ways of laying dice are the same if and only if the corresponding numbers of the dice of corresponding heights in both ways are facing the same.
Since the number of solutions may be too many, please output the result modulo 10^9 + 7.

Don't underestimate the number of dice at ATM~

"Input format"
The first line of two integers nm
n represents the number of dice
, the next m lines, each line of two integers ab, indicating that a and b cannot be closely together.

"Output format" is
one number per line, indicating the result of the answer modulo 10^9 + 7.

"Sample Input"
2 1
1 2

"Sample output"
544

"Data Range"
For 30% of the data: n <= 5
For 60% of the data: n <= 100
For 100% of the data: 0 < n <= 10^9, m <= 36
Question Analysis
Question Code



Question 10: The Tree of Life

Title Description
In the X forest, God created the tree of life.

He marked each node (the leaf is also called a node) of each tree with an integer representing the harmony value of this point.
God wants to select a non-empty node set S in this tree, so that for any two points a, b in S, there is a point column {a, v1, v2, ..., vk, b} such that this point Each point in the column is an element in S, and there is an edge between two adjacent points in the sequence.

Under this premise, God wants to make the sum of the integers corresponding to the points in S as large as possible.
This greatest sum is God's score for the tree of life.

After atm's efforts, he already knew the integers that God gave to every node on every tree. But since the atm is not good at calculations, he doesn't know how to get the score efficiently. He needs you to write a program for him to calculate the score of a tree.

An integer n in the first line of the "input format"
indicates that the tree has n nodes.
The second line contains n integers, which in turn represent the score of each node.
Next n-1 lines, each line contains 2 integers u, v, indicating that there is an edge from u to v. Since this is a tree, there are no cycles.

The "Output Format"
outputs a line with a number, indicating the score that God gave the tree.

"Sample Input"
5
1 -2 -3 4 5
4 2
3 1
1 2
2 5

"Sample output"
8

"Data Range"
For 30% of the data, n <= 10
For 100% of the data, 0 < n <= 10^5, the absolute value of the score of each node does not exceed 10^6.

Resource convention:
peak memory consumption (including virtual machine) < 256M
CPU consumption < 3000ms

topic analysis
topic code



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324763723&siteId=291194637