Sixth annual Blue Bridge Cup competition individual race (software Class) C++a Group Problem Solving report

Source: Internet
Author: User
Tags ming pear

"First question"
Equation Integer Solution

Equation: a^2 + b^2 + c^2 = 1000
(or see "Figure 1.jpg")
Does this equation have an integer solution? Yes: A,b,c=6,8,30 is a set of solutions.
Can you figure out a different set of solutions?

Please fill in the smallest number in the solution.

Note: You should submit an integer, do not fill in any superfluous content or descriptive text.

"The answer": Violence calculates another solution for the ten , so the smallest number is

"Second question"
Galaxy bomb

In the vast space of the X galaxy, many X-star man-made "bombs" were floated to serve as signposts in the universe.
Each bomb can be set to explode after a few days.
For example: The Alpha bomb was placed on January 1, 2015 and timed for 15 days, then it exploded on January 16, 2015.
There is a beta bomb, placed on November 9, 2014, timed for 1000 days, please calculate the exact date it exploded.

Please fill in the date in the format YYYY-MM-DD the 4-bit year 2-digit month 2-bit date. For example: 2015-02-19
Please write strictly in the format. No other text or symbols can appear.

"Answer" analysis is not known, (the problem on both sides of the scene hand: to find out 2017-08-02, do not know whether it is correct )

"The third question"

Wonderful numbers.

Xiao Ming found a wonderful figure. Its square and cubic meters just take the 0~9 10 numbers each and use them only once.
Can you guess how much this number is?

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

"Answer" 69*69=4761,69*69*69=328509

"Question fourth"


In-grid output

The Stringingrid function prints the specified string in a grid of a specified size.
Requires the string to be centered in a horizontal, vertical, two direction.
If the string is too long, it is truncated.
If you can't just center it, you can do it slightly to the left or to a point.

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

#include <stdio.h> #include <string.h> void stringingrid (int width, int height, const char* s) {    int i,k;
   char buf[1000];    strcpy (buf, s);    if (strlen (s) >width-2) buf[width-2]=0;        printf ("+");    for (i=0;i<width-2;i++) printf ("-");    printf ("+\n");        for (k=1; k< (height-1)/2;k++) {        printf ("|");        for (i=0;i<width-2;i++) printf ("");        printf ("|\n");    }        printf ("|");        printf ("%*s%s%*s", _______________________________________);  Fill in the blanks with                   printf ("|\n");        For (k= (height-1)/2+1; k


For the data in the topic, the output should be:
+------------------+
| |
| abcd1234 |
| |
| |
+------------------+

(See figure 1.jpg If there is an alignment problem)


Note: Fill in only what is missing, and do not write any existing code or descriptive text on any of the surfaces.

"The answer" is a good hole in the question.
%*s%s%*s
Star in the tangled Half-day, later after the game suddenly remembered is the format symbol, that is, the output format of the int type, the answer is:(width-1-sizeof (BUF)/2), "", Buf, (width-sizeof (BUF))/2-1, ""

"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.

#include <stdio.h> 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) printf ("%d/%d\n", A, b);} void f (int x[], int k) {    int i,t;    if (k>=9) {        test (x);        return;    }        for (i=k; i<9; i++) {        {t=x[k]; x[k]=x[i]; x[i]=t;}        f (x,k+1);        _____________________________________________//Fill in the Blanks    }}    int main () {    int x[] = {1,2,3,4,5,6,7,8,9};    f (x,0);        

Note: Fill in only what is missing, and do not write any existing code or descriptive text on any of the surfaces.
Answer{t=x[k]; x[k]=x[i];x[i]=t;}

/*
5832/17496
5823/17469
*/

" sixth " data loss, can not be affixed to the original question

" question Seventh"

Bracelet Style

Xiao Ming has 3 red coral, 4 white coral, 5 yellow agate.
He wanted to use them in a circle as a bracelet and give it to his girlfriend.
Now xiaoming would like to know: if you consider the bracelet can be rotated or flipped, how many different combinations can be?

Please submit the integer. Do not fill in any superfluous content or descriptive text.

"Answer" should be Polya count, did not make out, later to see the time to update the answer ~ ~

"Question eighth"
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.

"Answer": not sure at the moment.

"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 numbers cannot be glued 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 < 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: The main function needs to return 0
Note: Use only ANSI c/ansi C + + standards, and do not invoke special functions that depend on the compilation environment or operating system.
Note: All dependent functions must explicitly #include <xxx&gt in the source file, and the common header files cannot be omitted from the project settings.

When committing, be careful to choose the type of compiler you expect.

"Answer": not sure at the moment.

"question Tenth"
Post-disaster reconstruction

Pear City A total of n (<=50000) settlements, between the settlements have M (<=200000) two-way road connected. These settlements can be reached by two-way roads between 22. This has continued until recently, when a serious earthquake destroyed all M roads.
After the quake, Pear intends to repair some of these roads and to repair the time required for the route I roads need pi. However, Pear does not intend to allow all points to be connected, but instead chooses some special points to connect them.
Pear has a Q (<=50000) query, and each time he asks, he will select all numbers in [L,r], and the number mod K = C points, repair some roads to make them connected. As all roads are repaired at the same time, the time to complete the repairs depends on the longest route, i.e. the maximum value of the PI in the road involved.

Can you help pear calculate the minimum time to spend on each query? The inquiry here is independent, that is, the repair plan in the last inquiry was not put into action.

"Input Format"
The first line of three positive integers n, M, Q, meaning title face is described.
Next M-line, three positive integers per line XI, Yi, Pi, represents a two-way road connecting Xi and Yi, repairing the time required for Pi. There may be self-loops and there may be heavy edges. 1<=pi<=1000000.

Next Q line, four positive integers per line Li, Ri, Ki, Ci, indicating that the point of this inquiry is the [Li,ri] interval of all the numbered mod ki=ci points. Ensure that there are at least two points involved in the inquiry.

"Output Format"
The output Q line, a positive integer per line, indicates the answer to the corresponding query.

"Sample Input"
7 10 4
1 3 10
2 6 9
4 1 5
3 7 4
3 6 9
1 5 8
2 7 4
3 2 10
1 7 6
7 6 9
1 7 1 0
1 7 3 1
2 5 1 0
3 7 2 1

"Sample Output"
9
6
8
8

"Data Range"
For 20% of data, n,m,q<=30
For 40% of data, n,m,q<=2000
For 100% of data, n<=50000,m<=2*10^5,q<=50000. Pi<=10^6. Li,ri,ki are within the scope of [1,n], ci in [0, corresponding to the Ki of Inquiry).




Resource contract:
Peak memory Consumption < 256M
CPU Consumption < 5000ms


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: The main function needs to return 0
Note: Use only ANSI c/ansi C + + standards, and do not invoke special functions that depend on the compilation environment or operating system.
Note: All dependent functions must explicitly #include <xxx&gt in the source file, and the common header files cannot be omitted from the project settings.

When committing, be careful to choose the type of compiler you expect.

"Answer": not sure at the moment.

PS: The first Blue Bridge Cup, is considered to be the title of the pit to, also blame their strength is not enough, knowledge is not complete, is an experience, normal play is the biggest play! Come on!





Sixth annual Blue Bridge Cup competition individual race (software Class) C++a Group Problem Solving report

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.