[Counting sorting] vijos 1316 explicit Random Number

Source: Internet
Author: User
Background

No. 1 in noip2006 popularity Group

Description

I want to ask some students to do a questionnaire survey in school. In order to make the experiment objective, he first generates n random integers (n ≤ 1000) from 1 to 100 on the computer ), only one number is retained, and the remaining identical numbers are removed. Different numbers correspond to different student IDs. Then sort these numbers from small to large and sort them to the students for investigation. Please help clearly complete "de-duplication" and "sorting.

Format input format

There are two rows in the input, and 1st act as a positive integer, indicating the number of random numbers generated:
N
The first row contains n positive integers separated by spaces, which are the random numbers generated.

Output Format

The output is also two rows. 1st acts as a positive integer m, indicating the number of random numbers that are not the same. 2nd act M positive integers separated by spaces. They are random numbers in ascending order.

Example 1 input 1 [copy]
1020 40 32 67 40 20 89 300 400 15
Sample output 1 [copy]
815 20 32 40 67 89 300 400
Restrictions

All point 1 s

Really sad

# include<cstdio># include<cstring># include<iostream> # include<algorithm>using namespace std;const int maxn=1000+10;int num[maxn],tot;int main(){    memset(num,0,sizeof(num));    ios::sync_with_stdio(false);    int n,x;cin>>n;    for(int i=1;i<=n;i++){        cin>>x;        num[x]++;    }    for(int i=1;i<maxn;i++)if(num[i])tot++;    cout<<tot<<endl;    for(int i=1;i<maxn;i++)if(num[i])cout<<i<<" ";    return 0;}

 

[Counting sorting] vijos 1316 explicit Random Number

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.