Previous questions Error notesTime limit: 1.0s memory limit: 256.0MB
Problem Description
A certain secret unit issued a certain instrument, and to be fully recovered at the end of the year.
Each ticket has a unique ID number. All year round the ID number of the ticket is sequential, but the beginning of the ID is randomly selected.
Because the staff negligence, in the input ID number when an error occurred, resulting in an ID break number, and another ID number.
Your task is to programmatically find the ID of the broken number and the ID of the re-number.
It is assumed that the break number cannot occur in the maximum and the trumpet.
Input Format
Requires that the program first enter an integer N (n<100) to indicate the number of rows after the data.
Then read n rows of data.
Each row of data length, is separated by a space of several (not more than 100) positive integer (not greater than 100000), please note that there may be extra space in the line and at the end of the line, your program needs to be able to handle these spaces.
Each integer represents an ID number.
output Format
Requires that the program output 1 lines, including two integer m n, separated by a space.
where m means the id,n is the number ID
Sample Input 12
5 6 8) 11 9
10 12 9
Sample Output 17 9
Sample Input 26
164 178 108 109 180 155 141 159 104 182 179 118 137 184 115 124 125 129 168 196
172 189 127 107 112 192 103 131 133 169 158
128 102 110 148 139 157 140 195 197
185 152 135 106 123 173 122 136 174 191 145 116 151 143 175 120 161 134 162 190
149 138 142 146 199 126 165 156 153 193 144 166 170 121 171 132 101 194 187 188
113 130 176 154 177 120 117 150 114 183 186 181 100 163 160 167 147 198 111 119
Sample Output 2105 120
Java source code:
1 Importjava.util.ArrayList;2 Importjava.util.Collections;3 Importjava.util.List;4 ImportJava.util.Scanner;5 6 Public classMain {7 8 Public Static voidMain (string[] args) {9Scanner in =NewScanner (system.in);Ten intn =in.nextint (); OneString numline[] =NewString[n]; A in.nextline (); - for(inti = 0; I < n; i++) { -Numline[i] =in.nextline (). Trim (); the } -List<integer> nums =getnums (numline); - Collections.sort (nums); - intD =Getduan (nums); + intc =Getchong (nums); -System.out.println (D + "" +c); + } A at Private Static intGetchong (list<integer>nums) { - intc =-1; - intmax = Nums.size ()-1; - for(inti = 0; i < Max; i++) { - if(Nums.get (i). Intvalue () = = Nums.get (i + 1). Intvalue ()) { -c =Nums.get (i); in Break; - } to } + returnC; - } the * Private Static intGetduan (list<integer>nums) { $ intD =-1;Panax Notoginseng intmax = Nums.size ()-1; - for(inti = 0; i < Max; i++) { the if(Nums.get (i). Intvalue ()! = Nums.get (i + 1). Intvalue () +&& Nums.get (i) + 1! = Nums.get (i + 1)) { AD = Nums.get (i) + 1; the Break; + } - } $ returnD; $ } - - Private StaticList<integer>getnums (string[] numline) { theList<integer> nums =NewArraylist<integer>(); - for(inti = 0; i < numline.length; i++) {WuyiString n =Numline[i]; thestring[] ns = N.split (""); - for(intj = 0; J < Ns.length; J + +) { Wu if("". Equals (Ns[j])) - Continue; About Nums.add (Integer.parseint (ns[j)); $ } - } - returnnums; - } A}
Evaluation Point serial number |
Evaluation Results |
score |
CPU Usage |
Memory Usage |
Download Evaluation Data |
1 |
That's right |
50.00 |
171ms |
23.54MB |
Input/Output |
2 |
That's right |
50.00 |
234ms |
23.39MB |
Input/Output |
"Blue Bridge Cup" previous questions error notes