Sixth annual Blue Bridge Cup competition (software Class) Java University Group B

Source: Internet
Author: User
Tags ming

Haven't updated the blog for a long time, from the Blue Bridge Cup province began to update it.

First question:

Triangular area

As shown in 1. All the squares in the chart are 1 in size.
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 superfluous content or descriptive text.

Problem Solving Analysis: Direct calculation, 8x8-(8x4)/2-4x6/2-8x2/2=28, nothing to say

The second question:

Cubic Change itself

Observe the following phenomenon, the cubic of a 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
...


Would you please calculate the total number of positive integers that conform to this property, including 1,8,17?


Please fill in this number, do not fill in any superfluous content or descriptive text.

Package Two;public class Main {public static long sum (long a) {long sum=0;while (a/10>0) {sum+=a%10;a/=10;} Sum+=a;return sum;} public static void Main (string[] args) {int count=0;for (int i=1;i<10000;i++) {if (I==sum ((int) Math.pow (i, 3))) {count+ +; System.out.println (i);}} SYSTEM.OUT.PRINTLN ("Total" +count);}}

Output: 1817182627 Total 6


Question three:

Three goats to offer Rui
Observe the following addition calculation:

The auspicious omen is shining
+ Three sheep offering Rui
-------------------
San Yang Sheng Bling

(See figure 1.jpg If you have alignment issues)

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

Please fill in the 4-digit number (the answer is the only) represented by "San Yang Rui", do not fill in any superfluous content.


Answer:

9587
+ 1085
10652


Question Fourth:

Cycle section length
Two integers do division, sometimes producing repeating decimal, and its cyclic part is called: Follow the link.
For example, 11/13=6=>0.846153846153 ..... There are 6 bits in the cycle section [846153].
In the following way, you can find the length of the loop section.

Please read the code carefully and fill in the missing code in the underlined section.


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) _________________________________; Blanks
}
}


Note that you can only fill in the missing parts, and do not copy the existing code repeatedly. Do not fill in any extra text.

Answer: Return V.size ()


Question Fifth

Nine array Fractions

1,2,3...9 These nine numbers make up a fraction with a value of exactly 1/3, how does the group method work?

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

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);
_______________________________________//Fill in the blanks
}
}

public static void Main (string[] args)
{
int[] x = {1,2,3,4,5,6,7,8,9};
f (x,0);
}
}


Note that you can only fill in the missing parts, and do not copy the existing code repeatedly. Do not fill in any extra text.

answer: {int t=x[k]; x[k]=x[i]; x[i]=t;}

Question sixth:

Addition variable multiplication

We all know: 1+2+3+ ... + 49 = 1225
You are now asked to turn two of these nonadjacent plus signs into multiplication sign, making the result 2015

Like what:
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 front multiplication sign (for example, commit 10).

Note: You are required to submit an integer, do not fill in any superfluous content.

Package six;/** * April 11, 2015 14:51:20 * @author Figure le * */public class Main {public static void fun (int n,int sum,int count,ch AR last,stringbuffer sb) {if (n<50&&sum>=0) {sb.append (n); if (count>0&&last!= ' * ') {fun (n+1, sum-n* (n+1), count-1, ' * ', new StringBuffer (SB). Append ("*");} if (last== ' * ') fun (n+1,sum,count, ' + ', new StringBuffer (SB) Append ("+")); Elsefun (N+1,sum-n,count, ' + ', new StringBuffer (SB). Append ("+"));} if (n==50&&sum==0&&count==0) {System.out.println ("OK:" +sb.tostring ());}} public static void Main (string[] args) {fun (1, 2, ' ', New StringBuffer ())}}

Output: ok:1+2+3+4+5+6+7+8+9+10*11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27*28+29+30+31+32+33+34+35+36+37+38 +39+40+41+42+43+44+45+46+47+48+49+ok:1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16*17+18+19+20+21+22+23+24*25+26+27+ 28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+

Answer:


Question Seventh
Number of card types

Xiao Ming was hijacked to X Vegas and was forced to play cards with 3 other people.
A deck of poker (minus the size of ace, a total of 52), evenly distributed to 4 people, each 13 Zhang.
At this time, Xiao Ming's brain suddenly emerged a problem:
If you do not consider the suit, only consider the points, also do not consider the order of the cards you get, you can get the initial combination of the total number of types?

Please fill in this integer, do not fill in any superfluous content or descriptive text.


Resolution: Temporarily indeterminate


Question eighth:

Beverage Redemption

A promotional offer is being held at the Lok Yang Sheep beverage factory. Happy Goat C drink, with 3 caps can be replaced by a bottle of C-type beverage, and can continue to cycle, but do not allow credit.
Please calculate, if Xiao Ming does not waste the bottle cap, as far as possible to participate in activities, then, for his initial purchase of n bottles of drinks, finally he can get how many bottles of drinks.

Input: An integer n representing the number of drinks to start buying (0<n<10000)
Output: An integer representing 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 contract:
Peak memory consumption (with virtual machines) < 256M
CPU Consumption < 1000ms

Please strictly according to the requirements of the output, do not use the superfluous printing similar: "Please enter ..." Redundant content.


All the code is placed in the same source file, after debugging passed, the copy is submitted to the source.
Note: Do not use the package statement. Do not use jdk1.7 and the features of the above version.
Note: The name of the main class must be: main, otherwise it will be treated as invalid code.

Sample too,

Input

10000

Output
14999

Run time
3559

Timeout no doubt




Ask a great God, he gave a formula: (int) (n*3/2.0-0.5)

It's been seconds.


Package Eight;import java.util.scanner;/** *  * April 11, 2015 14:56:25 * @author Chart Music * */public class Main {//int [] Save = new Int[10005][2];p ublic static void Main (string[] args) {Scanner in = new Scanner (system.in); long s = System.currenttim Emillis (); System.out.println (f (In.nextint ())); Long E = System.currenttimemillis (); System.out.println ((e-s));} public static int  f (int n) {int count=0;int yushu=0;while (n>0) {count+=n;int temp=n;n= (N+yushu)/3;yushu= (temp+ Yushu)%3;} return count;}} <span style= "color: #ff0000;" ></span>
Forgot to submit the result format, perhaps the run time output, test with, not a few wrong words are not staggered


Question Nineth:

Base Dice

Gambling San ATM in the old age infatuated with the dice, is the dice one base on the other top, not crooked, to base solutionkeys column body.
After a long observation, ATM found the secret of stabilizing the dice: Some of the number of the surface will be mutually exclusive!
Let's start by standardizing the dice: 1 opposite is 4,2 opposite is 5,3 opposite is 6.
If there is an M-group mutex, the two-digit face of each group clings to one another, and the dice cannot stabilize the base. The ATM wants to calculate how many different possible ways to base the dice.
The two types of dice are the same, and the corresponding numbers of the dice corresponding to the height of the two methods are the same.
Because the number of scenarios may be too large, output modulo 10^9 + 7 results.

Do not underestimate the number of ATM dice Oh ~

"Input Format"
First row of two integers n m
n indicates the number of dice
The next m line, two integers a b per line, indicates that A and B cannot cling together.


"Output Format"
A row of a number that represents the result of the answer modulo 10^9 + 7.


"Sample Input"
2 1
1 2


"Sample Output"
544


"Data Range"
For 30% data: N <= 5
For 60% data: N <= 100
For 100% data: 0 < n <= 10^9, M <= 36




Resource contract:
Peak memory consumption (with virtual machines) < 256M
CPU Consumption < 2000ms




Please strictly according to the requirements of the output, do not use the superfluous printing similar: "Please enter ..." Redundant content.


All the code is placed in the same source file, after debugging passed, the copy is submitted to the source.
Note: Do not use the package statement. Do not use jdk1.7 and the features of the above version.
Note: The name of the main class must be: main, otherwise it will be treated as invalid code.


Parse None:


Question 10th:



Tree of Life


in the X forest, God created the tree of life.


He gives each node of each tree (the leaf is also called a node) an integer that represents the harmonious value of the point.
God wants to select a non-empty node set S in this tree, so that for any two points in S, a, there is a dot column {A, V1, v2, ..., VK, b} so that each point in this point column is an element of s inside, and there is an edge connected between two adjacent points in the sequence.


In this premise, God wants to make the points in s corresponding to the integers and as large as possible. The biggest sum of the
is God's score for the Tree of life.


After an ATM effort, he already knows the integers God gives to each node on each tree. But because ATM is not good at computing, he does not know how to effectively evaluate the score. He needs you to write a program for him to calculate the score of a tree.


Input format
The first line an integer n indicates that the tree has n nodes.
the second row n integers, which in turn represent the score for each node. The
Next n-1 line, 2 integers per line u, V, indicates that there is a U to v edge. Since this is a tree, there is no ring.


Output format
Output one line at a number representing the score God gave to this tree.


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 <=
for 100% of data, 0 < n <= 10^5, the absolute value of each node's score is not more than 10^6.


Resource contract:
Peak memory consumption (with virtual machines) < 256M
CPU consumption  < 3000ms




Please output strictly as required, do not print like this: " Please enter ... " Redundant content.


All code is placed in the same source file, and after debugging passes, the copy is submitted to the source.
Note: Do not use the package statement. Do not use jdk1.7 and the features of the above version.
Note: The name of the main class must be: main, otherwise it will be handled by invalid code.


Parse None:



Summing up, this is the second time to participate in the Blue Bridge Cup, generally speaking is not very satisfied, recently there are a lot of things in busy, and not how to prepare. Can only say that they are not hard enough, I hope to participate in the last game.

Sixth annual Blue Bridge Cup competition (software Class) Java University Group B

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.