Random number of 1122:hh time limit: 1 Sec Memory Limit: MB
Submit: 413 Solved: 60
[Submit] [Status] [Web Board] [Edit] Description
HH want to ask some students in the school to do a survey, for the objectivity of the experiment, he first used a computer to generate N 1 to 1000 random integer (n≤100), for the number of repetitions, only one, the rest of the same number is removed, the different numbers correspond to different student's number. Then the numbers from small to large sorting, in line with the order to find students to do the investigation. Please help clearly to complete the "go to Heavy" and "sort" work.
Input
There are 2 rows, and the 1th behavior is 1 positive integers, indicating the number of random numbers generated:
N
The 2nd line has n spaces separated by a positive integer, which is the resulting random number.
Output
is also 2 rows, the 1th Act 1 positive integer m, which represents the number of different random numbers. The 2nd behavior is a positive integer separated by a space, which is a different random number from small to large sequence.
Sample InputTen -A-Sample Output8 All in allHINT
Source
The fifth annual ACM Program Design Competition of Henan Polytechnic University
wrong six times. Later found that the end cannot output a carriage return. "I know the truth of my tears flow down." "
#include <stdio.h> #include <string.h> bool vis[1010]; int main () { int n, I, V, m; while (scanf ("%d", &n) = = 1) { memset (vis, 0, sizeof (VIS)); m = 0; while (n--) { scanf ("%d", &v); if (Vis[v]) continue; ++m; VIS[V] = 1; } printf ("%d\n", m); for (i = 1;!vis[i]; ++i); printf ("%d", I); while (i++ <) if (Vis[i]) printf ("%d", I); } return 0; }/************************************************************** problem:1122 user:changmu language:c++ result:accepted time:0 Ms memory:820 KB ********************************************* *******************/
HPU1122 HH's random number "pit"