Hand cheap, submitted wrong two order, estimated GG
First question:
I pit dad unexpectedly thought of with Helen Formula, calculated out 24.92708569439206 alas, directly minus the small not just finished ah ""
Answer: 8x8-(8x4)/2-4x6/2-8x2/2=28
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?
It should be a language primer,
public class Main {public static void solve () {}static long n,m;static long [] num = null;public static void Main (string[] args) {Long ans = 0;for (long n = 1;n<10000;n++) {Long tot = N*n*n;long cmp = 0;long t = tot;while (t!=0) {cmp +=t%10;t/=1 0;} if (cmp = = N) {ans++; SYSTEM.OUT.PRINTLN (n);}} System.out.println ("Answer:" +ans);}} 1//8//17//18//26//27//answer: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
Among them, the same Chinese characters represent the same numbers, and the different Chinese characters represent different numbers.
Please fill in the 4 digits represented by "San Yang" (the answer is the only one)
This is a mess.
9 5 6 7
1 0 8 5
1 0 6) 5 2
Question Fourth:
Import Java.util.vector;public class Main {//circular section length////two integers to divide, sometimes produces repeating decimal, the loop 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) return v.size ()-v.indexof (n); Fill in the blanks}}//note that only the missing parts can be filled, do not repeat the existing code. Do not fill in any extra text. public static void Main (string[] args) {System.out.println (f (11,13)); System.out.println (f (11,17));}}
Question Fifth:
Nine array fraction////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 Main{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); {int t=x[k]; x[k]=x[i]; x[i]=t;} Fill in the blanks, this is the whole arrangement.}}public static void Main (string[] args) {int[] x = {1,2,3,4,5,6,7,8,9};f (x,0);}}
Question sixth:
This is just a test, OK. Answer: 16
Addition variable multiplication////we all know: 1+2+3+ ... + 49 = 1225//now requires you to turn two of these nonadjacent plus signs into multiplication sign, making the result 2015////such as://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. Import Java.util.arrays;import Java.util.vector;public class Main {public static void solve () {}static long n,m;static lon G [] num = null;public static void Main (string[] args) {int pre = 1225;for (int p = 1;p<47;p++) {for (int pp = p+2;pp<4 9;pp++) {int now = Pre, now-= p+p+1;now-= Pp+pp+1;now + p* (p+1); now + = pp* (pp+1); if (now==2015) System.out.println (p+ "" + PP);}}}
Question seventh:
The direct DP is resolved, but the exam is the wrong time to read the question,...............................................
Import Java.util.arrays;import Java.util.scanner;public class Main {static int []num = new int[170];static int ans = 0;pub Lic static void Main (string[] args) {int [][]DP = new int[14][14];DP [0][0]=1;for (int i = 1;i<14;i++) for (int j = 0;j< 14;j++) for (int k = 0;k<5;k++) if (j+k<=13) dp[i][j+k] +=dp[i-1][j]; System.out.println (dp[13][13]);}} 3598180
Question eighth:
Pay attention to each calculation to get the cap of the single drop
Beverage Redemption////sheep and goat Beverage Factory is hosting a promotional offer. 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, indicating the number of drinks to be purchased (0<n<10000)//output: An integer that represents the actual number of drinks////for example://USER input://100//program should output://149////user input://101// The program should output://151//////resource contract://Peak memory consumption (including virtual machine) < 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. Import Java.util.arrays;import Java.util.scanner;public class Main {public static void main (string[] args) {Scanner in = n EW Scanner (system.in); int n = in.nextint (); int ans = 0;int mod = 0;while (n!=0) {ans +=n;int t = n;if (t%3+mod>=3) {n = T/3 +1;mod = (t%3+mod)-3;} Else{n = T/3;mod + = t%3;}} System.out.println (ANS);}}
Question Nineth:
Recursion, you have to use the matrix to accelerate it, Java write too uncomfortable to write, directly naked
import Java.util.arrays;import Java.util.scanner;public class Main {static int MOD = (int ) (1e9+7);p ublic static void Main (string[] args) {int [][]ar = new Int[40][40];int []mm = {0,4,5,6,1,2,3};long [][]DP = ne] W Long[2][7]; Scanner in = new Scanner (system.in), int n = in.nextint (); int m = In.nextint (); for (int i = 0;i<m;i++) {int u = In.nextin t (); int v =in.nextint (); Ar[u][v] = 1;ar[v][u] = 1;} int pre = 1;int now = 0;for (int i = 1; i < 7; i++) Dp[0][i] = 4;for (int i = 2; I <= n; i++) {pre = (pre + 1)% 2;no W = (now + 1)% 2; Arrays.fill (Dp[now], 0); for (int j = 1; j < 7; J + +) for (int k = 1;k<7;k++) {Dp[now][j] + = (dp[pre][k] * 4)% MOD;} for (int j = 0, J < 7; J + +) {for (int k = 0;k<=j;k++) if (ar[j][k]==1) {dp[now][mm[j]] = (MOD + dp[now][mm[j])-Dp[pre ][K] * 4)% mod;dp[now][mm[k]] = (mod + dp[now][mm[k]-dp[pre][j] * 4)% MOD;}} Long ans = 0;for (int i = 1; i < 7; i++) ans = (ans + dp[now][i])% MOD; System.out.println (ANS);}}
Question Tenth:
LCA problems. Test instructions and samples do not correspond, strange ... Definitely timed out.
The Tree of Life////in the X forest, and God created the tree of life. He gives each node of each tree (the leaf also known as 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. This is the greatest and is God's rating of the Tree of life. Through the efforts of ATM, he already knew God gave every tree on each node of the integer. 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. Next n-1 line, 2 integers per line u, V, indicates the existence of a U to v edge. Since this is a tree, there is no ring. The 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 <= 10//for 100% data, 0 < n <= 1 0^5, the absolute value of each node's score does not exceed 10^6. Resource contract://Peak memory consumption (with virtual machine) < 256M//CPU consumption < 3000msimport Java.util.arrays;import Java.util.scanner;public class Main {static int [] head1 = new int [100010];static int [] head2 = new int [100010];static int [] node = new int [100010];stati C Edge []edge1 = new Edge[300010];static edge []edge2 = new edge[300010];static int [] degree = new int [100010];static in t [] fa = new int [100010];static int tot1 = 0,TOT2 = 0;static int node;static long [] max = new long[100010];static long ans = long.min_value;sta tic void add1 (int u,int v) {edge1[tot1].u = U;EDGE1[TOT1].V = V;EDGE1[TOT1].NXT = Head1[u];head1[u] = tot1++;} static void add2 (int u,int v) {edge2[tot2].u = U;EDGE2[TOT2].V = V;EDGE2[TOT2].NXT = Head2[u];head2[u] = tot2++;} static void Dfs (int u,int par,long nn) {Max[u] = Nn;fa[u] = u;for (int i = head1[u];i!=-1;i=edge1[i].nxt) {int v = EDGE1[I].V , if (V==par) Continue;dfs (V,u,nn+node[v]); fa[v] = u;} for (int i = head2[u];i!=-1;i=edge2[i].nxt) {int v = edge2[i].v;if (Max[v]!=long.max_value) {ans = Math.max (ans, max[v]+max [U]-max[parent (v)]);}}} static int parent (int x) {if (Fa[x]==-1 | | fa[x]==x) return X;return fa[x] = parent (fa[x]);} public static void Main (string[] args) {Scanner in = new Scanner (system.in); Node = In.nextint (), for (int i = 0;i<node;i++) node[i] = In.nextint (), for (int i = 0;i<=node+node;i++) edge1[i] = new Ed GE (); for (int i = 0;i<=node*node*2;i++) edge2[i] = NEW Edge (); Arrays.fill (FA,-1); Arrays.fill (Head1,-1); Arrays.fill (Head2,-1); Arrays.fill (max, long.max_value); for (int i = 1;i<node;i++) {int u,v;u = In.nextint () -1;v = In.nextint () -1;degree[u]++ ;d egree[v]++;add1 (u,v); Add1 (v,u);} for (int i = 0;i<node;i++) for (int j = 0;j<node;j++) {add2 (i,j); Add2 (j,i);} if (node==2) {System.out.println (node[0]+node[1]); return;} DFS (0,-1,node[0]); System.out.println (ANS);}} Class Edge{int u,v,nxt;int par;}
The sixth annual Blue Bridge Cup provincial java-b full analysis