Team C ++ group A solution report for the sixth session of the Blue Bridge cup individual competition (software), Blue Bridge Software

Source: Internet
Author: User
Tags pear value of pi

Team C ++ group A solution report for the sixth session of the Blue Bridge cup individual competition (software), Blue Bridge Software
[Question 1]
Integer Solution
 
Equation: a ^ 2 + B ^ 2 + c ^ 2 = 1000
(Or see Figure 1.jpg ])
Is there an integer solution for this equation? There are: a, B, c = 6, 8, 30 is a group of solutions.
Can you work out another suitable solution?
 
Enter the minimum number in the solution.
 

Note: You must submit an integer and do not enter any additional content or descriptive text.

[Answer]: The other solution for brute force computing is 10 18 24, so the minimum number is 10.

[Question 2]
Galaxy bomb
 
In the vast space of Galaxy X, a number of X-star man-made "bombs" floated as signs of the universe.
Each bomb can be set to how many days later to explode.
For example, if the Alpha bomb was placed on February 15, January 1, 2015 for a period of 15 days, it exploded on February 15, January 16, 2015.
There is a beta bomb, which will be placed in December November 9, 2014 and is scheduled to be 1000 days. Please calculate the exact date of its explosion.
 
Enter the date in the format of yyyy-mm-dd, that is, four-digit year, two-digit month, two-digit date. Example:
Please strictly follow the format. Other text or symbols are not allowed.

[Answer] the resolution is unknown. (I calculated both sides of this question: 2017-08-02. I wonder if it is correct)

[Question 3]

Amazing numbers
 
James found a wonderful number. The sum of squares and cubes of the sum is 0 to 0 ~ The 10 digits of 9 are used and used only once.
Can you guess the number?
 
Enter this number. Do not enter any additional content.

[Answer] 69 69*69 = 4761,69*69*69 = 328509

[Question 4]


Grid output
 
The StringInGrid function prints the specified string in a grid of the specified size.
The string must be centered horizontally and vertically.
If the string is too long, it is truncated.
If it cannot be centered exactly, you can make it a little left or a little above.
 
The following program implements this logic. Enter the code that is missing in the dashes.
 

# 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", _______________________________________); // fill in printf ("| \ n "); for (k = (height-1)/2 + 1; k 


Data in the question should be output:
+ ------------------ +
|
| Abcd1234 |
|
|
+ ------------------ +
 
(See Figure 1.jpg if the question is correct ])
 
 
Note: enter only the missing content. Do not write any existing code or descriptive text on the Question surface.
 
[Answer] This question is a pitfall.
%*s%s%*s
The asterisks tangled for a long time, then after the game suddenly remembered is the format symbol, that is, the int type output format, the answer is: (width-1-sizeof (buf)/2), "", buf, (width-sizeof (buf)/2-1 ,""

Question 5]


9. array score
 
The nine numbers 1/3, 3... 9 constitute a score with a value of exactly. How to group the score?
 
The following program implements this function. Enter the code missing in the dash 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 ); _____________________________________________ //} int main () {int x [] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; f (x, 0); return 0 ;}

Note: enter only the missing content. Do not write any existing code or descriptive text on the Question surface.
[Answer] {t = x [k]; x [k] = x [I]; x [I] = t ;}

/*
// 5832/17496
// 5823/17469
*/

Question 6] Card type

James was hijacked to gambling city X and forced to play cards with three others.
A pair of playing cards (52 cards in total, excluding the trump card size) were evenly distributed to four people, each with 13 cards.
At this moment, James suddenly encountered a problem in his mind:
If you do not consider the color, only the number of points, or the order of the cards you get, how many initial card combinations can you get?

Enter this integer, and do not enter any additional content or instructions.

[Answer]: I am not sure yet.

Question 7]

Bracelet Style
 
James has 3 red coral, 4 white coral, and 5 yellow agate.
He wants to use them in a chain to give them to his girlfriend.
Now I want to know: How many different combination styles can a bracelet rotate or flip freely?
 
Please submit this integer. Do not enter any additional content or descriptive text.

[Answer] It should be the polya count, which has not been made. Let's see the time to update the answer later ~~

Question 8]

Change the beverage cover,

Core code:

while(n/3){    sum+=n/3;    n=n/3+n%3;}

Question 9]
Base dice
 
In old age, the gambling atm is infatuated with the base dice, that is, putting the dice on the top of the other. It cannot be twisted and twisted to form a square column.
After a long period of observation, atm has discovered the mystery of the stable dice: some numbers are mutually exclusive!
Let's regulate the dice first: the opposite of 1 is 4, the opposite of 2 is 5, and the opposite of 3 is 6.
Assuming that m groups are mutually exclusive, and the two digits in each group are closely tied together, the dice cannot be stabilized.
The atm wants to calculate how many different possible base dice methods are available.
The two dice have the same method. If and only when the two dice have the same orientation as the number corresponding to the height.
Because the number of solutions may be too large, please output the result of MOD 10 ^ 9 + 7.
 
Don't underestimate the number of dice in the atm ~
 
"Input format 」
The first line has two integers, n m.
N indicates the number of dice.
In the next m row, each row has two integers, a B, indicating that the numbers a and B cannot stay together.
 
"Output format 」
The number of rows indicates the result of the 10 ^ 9 + 7 modulus of the answer.
 
「 Example input 」
2 1
1 2
 
「 Sample output 」
544
 
「 Data Scope 」
For 30% of data: n <= 5
For 60% of data: n <= 100
For 100% of data: 0 <n <= 10 ^ 9, m <= 36
 
 
Resource conventions:
Peak memory consumption <256 M
CPU consumption <2000 ms
 
 
Please output strictly as required. Do not print anything that is similar to "Please input.
 
All codes are stored in the same source file. After debugging is successful, copy and submit the source code.
 
Note: The main function must return 0.
Note: Only ansi c/ansi c ++ standards are used. Do not call special functions that depend on the compiling environment or operating system.
Note: All dependent functions must be explicitly included in the source file # include <xxx>. Common header files cannot be omitted through engineering settings.
 
When submitting, select the expected compiler type.
 

[Answer]: I am not sure yet.

Question 10]
Post-disaster reconstruction
 
Pear City has a total of N (<= 50000) residential areas, M (<= 200000) two-way road connection between residential areas. These residential areas can all be reached through two-way roads. This situation continued until recently, and a serious earthquake destroyed all M roads.
After the earthquake, Pear planned to repair some of the roads, and it would take Pi time to repair the I-th Road. However, Pear does not intend to connect all vertices, but rather chooses some special vertices to connect them.
Pear has a Q (<= 50000) query. In each query, he selects all vertices with numbers between [l, r] And mod K = C, repair some paths to connect them. Because repairs on all roads can start at the same time, the time needed to complete the repairs depends on the longest route, that is, the maximum value of Pi in the road involved.
 
Can you help Pear calculate the minimum time required for each query? The inquiry here is independent, that is, the repair plan in the previous inquiry has not been put into action.
 
[Input format]
The three positive integers N, M, and Q in the first line are described in the question.
In the next M row, each row has three positive integers Xi, Yi, and Pi, indicating a two-way road connecting Xi and Yi. The time required for Pi is fixed. There may be a self-ring and a duplicate edge. 1 <= Pi <= 1000000.
 
In the next row of Q, each row contains four positive integers: Li, Ri, Ki, and Ci, indicating that the point of this query is the point of all number Mod Ki = Ci in the [Li, Ri] range. Ensure that there are at least two points involved in the inquiry.
 
[Output format]
Output Q rows. Each row has a positive integer representing the answer to the query.
 
[Example 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 Scope]
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, and Ki are in the range of [1, N], and Ci is in the range of [0, corresponding to the queried Ki.
 
 
 
 
Resource conventions:
Peak memory consumption <256 M
CPU consumption <5000 ms
 
 
Please output strictly as required. Do not print anything that is similar to "Please input.
 
All codes are stored in the same source file. After debugging is successful, copy and submit the source code.
 
Note: The main function must return 0.
Note: Only ansi c/ansi c ++ standards are used. Do not call special functions that depend on the compiling environment or operating system.
Note: All dependent functions must be explicitly included in the source file # include <xxx>. Common header files cannot be omitted through engineering settings.
 
When submitting, select the expected compiler type.
 
 

[Answer]: I am not sure yet.

PS! Come on!

 



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.