Java Blue Bridge rainfall

[Problem Description]
due to long years of drought country sand, Master Xiao Ming ready to use his magic to a mysterious rain. This spell need to use his hands 49 magic symbols, above which were written 1-49 49 digits. Spell lasted seven weeks, Bob Fu every day using a spell, the spell breaks can not be reused. Weekly, Xiaoming cast energy median week 7 magic spell on the digital symbols produced. After seven weeks complete cast spells, rain will be successful, the median rainfall for the seven weeks of energy. Because of the drought too long, Little hope for rain rainfall as large as possible, please big is the maximum number?
[Answer] submit
this is a result of fill in the blank questions, you only need to calculate and submit the results. The results of this question is an integer, when submitting answers only to fill in the integer, fill in the extra content will not score.
Analysis: Therefore, the basic arrangement is the basic
27 28 29 30 31 is 32 33 is
20 is 21 is 22 is 23 is 24 25 26 is
13 is 14 15 16. 17 18 is. 19
10. 11 12 is 34 is 35 36 37 [
. 7. 8. 9 38 is 39 40 41 is
. 4. 5. 6 42 is 43 is 44 is 45
12346474849
in the median of all the summing;
code is as follows:
public static void main (String [] args) {
new new a int int [] = [49];
int B [] = new new int [49];
int SUM = 0, m = 0;
// assignment
for (int I = 0; I <a.length; I ++) {
a [I] = I +. 1;
}
// the array are arranged into a b,
for (int i = 0; i <7; i ++) {// there are seven weeks
for (int I = J 3; J <I 3 + 7; J ++) {// get seven digit
if (j <(i + 1 ) 3) {// 3 digits before assigned B
B [J] = a [J];
}
the else
B [J] = a [49 + 2-JI];
}
SUM = SUM + B [I +. 6
. 3]; // the median weekly several were summed
}
System.out.println (SUM);
}
}
algorithm of this code may not be perfect, if there is a better algorithm lot of advice, thank you! ! !

Published 13 original articles · won praise 0 · Views 121

Guess you like

Origin blog.csdn.net/vi_to/article/details/104796605