1598: Wrong bills of the previous questions

Source: Internet
Author: User
Tags unique id
Obviously and others method, copy someone else's code, but read into always the second line will begin to read ...

//See You again someday Description

A secret-related unit has issued some kind of bill and has to withdraw it at the end of the year.

Each ticket has a unique ID number. The ID number of all bills is continuous throughout the year, but the starting digit of the ID is randomly selected.

Because the staff negligence, in the entry ID number of a mistake occurred, resulting in a certain ID number, another ID number.

Your task is to programmatically identify the ID of the broken number and the ID of the heavy number. Suppose the broken number cannot occur in the largest and most small. Input

Requires that the program first enter an integer N (n<100) to represent the number of subsequent rows of data.

Then read n rows of data.

The length of each row of data, is separated by a number of (no more than 100) positive integers (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 requires that the program outputs 1 rows, containing two integers m n, separated by a space.

where m represents the Id,n ID of the number of broken numbers
Sample Input

Sample Input 1
2
5 6 8 One 9 
9

Samples input 2
6
164 178 108 109 180 155 141 159 104 182 179 118 137 184 115 124 129 196 172 189 127 112 131 169 158 128 102 148 139 157
185 152 135 1  123 173 122 136 174 191 145 116 151 143 175 161 134 162 190
149 138 142 146 199 126 165 156 153 193 144 166 170 121 171 132 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
Sample output: 1
7 9

Sample output 2
105 120
Import java.util.*;
public class Main {public
		 
	    static void Main (string[] args) {
	        Scanner input = new Scanner (system.in);
	        int N = Input.nextint ();
	        Input.nextline ();
	        Int[] A = new int[10006];
	        int m = 0;
	        while (Input.hasnextint ()) {
	            A[m] = Input.nextint ();
	            m++;
	             
	        }
	        Arrays.sort (A, 0, m); 
	        for (int i = 1; i < m i++) {if
	            (A[i]!= a[i-1] + 1 && a[i]!= a[i-1])//note plus restriction a[i]!=a[i-1], otherwise if the duplicate The number will go wrong before the count is broken
	            {
	                System.out.print (A[i]-1 + "");
	                break;
	            }
	        }
	        for (int i = 1; i < m i++) {
	            if (a[i] = = A[i-1]) {
	                System.out.print (a[i));
	                Break;}}}
	 
	

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.