test questions C: Total score of combined test : 10 branch

[ Problem description ]

Neocoronavirus is caused by neocoronavirus , Recently in A National spread , In order to control the epidemic as soon as possible , A China plans to test large numbers of people for virus nucleic acid .

however , Shortage of test kits .

In order to solve this problem , Scientists have come up with a way : Combined well detection . Coming from multiple people (k individual ) The collected samples were put into the same kit for detection . If the result is negative , This means that k All of them are negative , It's done with a reagent disk k Personal testing . If the result is positive , At least one person is positive , It needs to be changed k All individual samples were tested independently again ( In theory ,. If the test is cute k-1 All of them are negative, so we can infer the second k The individual is positive , But this inference will not be used in practice , It will k Individual independent testing ), Add the initial merge detection , A total of k+1 One kit is complete k Personal testing .

A China estimates that the infection rate of the people tested is about 1%, It is evenly distributed . Excuse me? k How much is the most economical kit ?

[ Answer submission ]

This is a case - Fill in the blanks , You just need to work out the results and submit them . The result of this question is - - An integer , Only fill in this integer when submitting the answer , Fill in the extra content will not be able to score .
answer :10
package com.Test.Demo. The 11th Blue Bridge Cup ; public class Main_C { public static void main(
String[] args) { int min=999990; int ans=-1; for(int i=1;i<=100;i++){ //i One by one
int temp; if(100%i!=0){ temp = 100/i+i+1; }else{ temp = 100/i+i; } if(min>temp){
min=temp; ans=i; } } System.out.println(ans); } }
The 11th Blue Bridge Cup needs more software 》Javm university B group

test questions H: String encoding

time limit : 1.0e Memory limit : 512.0MB Total score of this question : 20 branch

[ Problem description ]

Xiao Ming invented a way to encode a string of all capital letters . For each capital letter , Xiao Ming transforms it into the one it is in 26 Serial number in English letters , Namely A- LB-2…Z-26.

So a string can be converted to - A sequence of numbers :

such as ABCXYZ + 123242526.

Now give a converted sequence of numbers , Xiao Ming wants to restore the original string . Of course, such a restore may have multiple strings that meet the conditions . Xiao Ming wants to find the string with the largest dictionary order ,

[ Input format ] A sequence of numbers .

[ Output format ]

A string containing only uppercase letters , Represents the answer

[ sample input ]123242526

[ sample output ]LCXYZ

[ Scale and convention of evaluation case ]

about 20% Use cases for profit evaluation , The length of the input does not exceed 20. Do all evaluation cases , The length of the input does not exceed 20000.
import java.util.Scanner; public class Main { public static void main(String[]
args) { Scanner input = new Scanner(System.in); String s = input.next(); int len
= s.length(); char[] c = s.toCharArray(); int i; for(i = 0; i < len-1; i++) {
int a = c[i]-'0'; int b = c[i+1]-'0'; int ans = a*10+b; if(ans<27) { char ch = (
char) (ans+64); System.out.print(ch); i++; }else { char ch = (char) (a+64);
System.out.print(ch); } } if(i < len){ char ch = (char) (c[i]-'0'+64); System.
out.print(ch); } } }
test questions I: BST The problem of inserting nodes

time limit : 1.08 Memory limit : 512.0MB Total score of this question : 25 branch

[ Problem description ]

Given a - Tree contains N Binary tree with nodes , The node number is 1~N. among i Node number has weight w, And it just forms the weights of these nodes - A sort binary tree (BST).

Now give a node number K, Xiao Ming wants to know , Here it is N Beyond one weight , How many are there X( Namely X It doesn't mean anything W) satisfy : Number to K Add a weight of X Child nodes of , You can still get one BST.

For example, in the figure below , Numbers outside brackets indicate numbers , The numbers in brackets indicate the weight . I.e. number 1~4 The node weights are 0,10,20,30.





If K-1, So the answer is 0. because 1 Node number has left and right child nodes , No more child nodes can be added .

If K=2, So the answer is infinite . Because any negative number can be used as a 2 Left child of .

If K=3, So the answer is 9. because X= 12…19 Can be used as 3 Left child of .

[ Input format ]

The first line contains 2 An integer N and K.

following N Each line contains 2 An integer , Among them, No i Line is numbered i The number of the parent node of the node P And weight W. be careful P-0 express 1 Is the root node .

Input guarantee is a tree BST.
import java.util.Scanner; public class Main { public static void main(String[]
args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k =
input.nextInt(); int a[] = new int[100100]; int b[] = new int[100100]; int vis[
] = new int[100010]; for(int i = 1; i <= n; i++) { a[i] = input.nextInt(); b[i]
= input.nextInt(); vis[i] = a[i]; } int cnt = 0; int ans = 0; for(int i = 1; i
<= n; i++) { if(vis[i]==k) { cnt++; ans = b[i]; } } if(cnt==2) System.out.print(
0); else if(cnt==1) { ans = Math.abs(ans-b[k]); System.out.print(ans-1); }else
System.out.print(-1); } }

©2020 ioDraw All rights reserved
C# The name space of python To solve the problem of dictionary writing list in 【 skill 】 Simple solutions Mac Insufficient disk space use python turtle Drawing simple strokes C Language implementation of minesweeping game CLion Novice step on the pit :CMake project is not loaded I wish you all the best ( element ) Happy Lantern Festival ! Let's guess lantern riddles sewer , Dead rat , faeces ...... The smell is dregs in front of it 2020 Qizhi Developer Conference , These open classes are not to be missed !Mac disk space “ second ” Lose weight , Just because of this step of God operation !