Hash of the first m of hdu 1280

Source: Internet
Author: User

Hash of the first m of hdu 1280
First m Big DataTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 10574 Accepted Submission (s): 3686


Problem Description Do you still remember the assignment that Gardon assigned to John? (1005 in the last game) In fact, xiaoxi has recovered the original data table. Now she wants to confirm whether her answer is correct, but the answer is a huge table, xiaoxi only wants you to tell her the maximum M number in the answer.
Given a sequence of positive integers containing N (N <= 3000), each number cannot exceed 5000, and the N * (N-1)/2 sum of them, find the number (M <= 1000) of the First M and sort it in the ascending order.
The Input may contain multiple groups of data. Each group of data includes two rows:
The first row has two numbers N and M,
The number of N in the second row indicates the sequence.


Output outputs the number of M for each group of input data, indicating the result. The output should be arranged in ascending order.
Sample Input

4 41 2 3 44 55 3 6 4

Sample Output
7 6 5 511 10 9 9 8

Count the number of times each number appears and then output from large to small
#include
 
  #include
  
   int main(){    int hash[10010];    int a[3010];    int n,m;    int i,j;    while(scanf("%d %d",&n,&m)!=EOF)    {        memset(hash,0,sizeof(hash));        for(i=0;i
   
    xx)                {                    xx=a[i]+a[j];                }            }        }        for(i=xx;i>=0;i--)        {            while(hash[i]&&m>1)            {                printf("%d ",i);                hash[i]--;                m--;            }            if(m==1&&hash[i])            {                printf("%d\n",i);                break;            }        }    }    return 0;}
   
  
 


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.