2015 6th Java Group B Blue Bridge Cup Provincial Competition Real Questions

Here is the topic column of the Blue Bridge Cup over the years. It will be updated and will release the real questions and answers from previous years. Welcome friends to pay attention to me. Your likes and attention are the best motivation for me! ! !
Update one real question every day, so stay tuned

Lanqiao Cup Past Papers and Detailed Answers


Question 1: Area of ​​the triangle

The title description
is shown in Figure 1. The area of ​​all the small squares in the figure is 1.
So, what should be the area of ​​the triangle in the figure?
Please fill in the area of ​​the triangle. Do not fill in any redundant content or explanatory text.
Insert picture description here

Topic analysis
topic codes



Question 2: The cube becomes itself

Title description
Observe the following phenomenon, the cube of a certain number, 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

Could you please count the number of positive integers that fit this property, including 1, 8, 17?

Please fill in the number, do not fill in any redundant content or explanatory text.
Topic analysis
topic codes



The third question: Three sheep offer Rui

Title description
Observe the following addition formula:

      Auspicious brilliance 
  + Three sheeps offering Rui 
------------------- 
   Three sheeps radiating aura

(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 digits represented by "Sanyang Xianrui" (the answer is only), and do not fill in any redundant content.
Topic analysis
topic codes



Question 4: Length of cyclic section

Title description
Dividing two integers will sometimes produce cyclic decimals. The cyclic part is called: cyclic section.
For example, 11/13=6=>0.846153846153... Its loop section is [846153] and there are 6 digits in total. 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 codes



Question 5: Nine group scores

Title description
1,2,3...9 These nine numbers form a score, and its value is exactly 1/3. How to group it?

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 codes



Sixth question: Addition to multiplication

Title description
We all know: 1+2+3+… + 49 = 1225
Now you are required to turn the two non-adjacent plus signs into multiplication signs, making the result 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 multiplication sign in the front position (for example, submit 10).

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



Question 7: Number of card types

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

Please fill in the whole number, do not fill in any extra content or explanatory text.
Topic analysis
topic codes



Question 8: Drink redemption

Topic description
Leyangyang Beverage Factory is holding a promotional activity. For Leyangyang Type C Beverage, you can exchange for another bottle of Type C Beverage with 3 caps, and it can be recycled forever, 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 bottles of drinks he can get in the end.

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

For example:
User input:
100 The
program should output:
149

User input:
101 The
program should output:
151

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



Question 9: Base dice

Title description The
gambling atm became obsessed with dice in his later years, that is, he puts the dice on top of the other, not crooked, and has to be square cylinders.
After long-term observation, ATM has discovered the mystery of stable dice: the faces of some numbers will repel each other!
Let's first standardize the dice: the opposite of 1 is 4, the opposite of 2 is 5, and the opposite of 3 is 6.
Assuming that there are m groups of mutual exclusion, the faces of the two numbers in each group are close to each other, and the dice cannot stand up stably. Atm wants to calculate how many different possible ways to base the dice.
The two ways to base the dice are the same, if and only if the directions of the corresponding numbers of the dice of the corresponding height in the two ways are the same.
Since there may be too many solutions, please output the result modulo 10^9 + 7.

Don’t underestimate the number of dice in ATM~

The
two integers nm
n in the first line of the "input format" represent the number of dice. The
next m lines have two integers ab in each line, indicating that a and b cannot be close together.

"Output Format" has
a number on a line, which means the answer modulo 10^9 + 7.

"Sample Input"
2 1
1 2

"Sample Output"
544

"Data range"
of 30% of the data: n <= 5
data for 60%: n <= 100
to 100% of the data: 0 <n <= 10 ^ 9, m <= 36
Title Analysis
entitled Code



Question 10: Tree of Life

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

He marked an integer on each node (leaf is also called a node) of each tree, 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 sequence {a, v1, v2, …, vk, b} such that this point Each point in the column is an element in S, and there is an edge connected 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 largest sum is the score given by God to the tree of life.

After atm's efforts, he already knew the integer that God gave to each node on each tree. But because ATM is not good at calculation, he doesn't know how to effectively score. He needs you to write a program for him to calculate the score of a tree.


An integer n in the first line of "Input Format" means that the tree has n nodes.
The n integers in the second row represent the score of each node in turn.
In the 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 is no ring.

The "output format"
outputs a number on a line, representing the score given to this tree by God.

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

"Sample Output"
8

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

Resource agreement:
peak memory consumption (including virtual machines) <256M
CPU consumption <3000ms

Topic analysis
topic codes



Guess you like

Origin blog.csdn.net/kiwi_berrys/article/details/111493977