NYOJ 285 search for clone (map + count)

Source: Internet
Author: User
Tags cmath

NYOJ 285 search for clone (map + count)

Description

 

A town in the United States was recently attacked by aliens. Some residents were taken away and cloned. Now, scientists have extracted the DNA of some people in the town. Please find out the number of DNA with the same number of clones, for example, the following nine Sequences

AAAAAA
ACACAC
GTTTTG
ACACAC
GTTTTG
ACACAC
ACACAC
TCCCCC
TCCCCC
Here, TCCCCC and GTTTTG have two identical individuals, four for ACACAC and one for AAAAAA respectively, then the number of corresponding lines is output.

The first row 1, the second row 2, and the fourth row 1. The other rows output 0, 9 rows in total.

The number of input sequences cannot exceed 20000, and each sequence cannot exceed 20 characters
Input ends with 0

For example, describe the output in the question.

9 6AAAAAAACACACGTTTTGACACACGTTTTGACACACACACACTCCCCCTCCCCC0 0
Sample output
120100000

Question Analysis:

The question is that finding and outputting the number of strings that appear I times is a map + counting problem. Use an array a [] to record the number of occurrences, for example, a [I] = 4; to indicate that the number of occurrences of I is 4.

 

AC code:

 

/*** Hash + count */# include
       
        
# Include
        
         
# Include
         # Include
          
           
# Include
           
            
# Include
            
              # Include
             
               # Include
              
                # Include
               
                 # Include
                
                  # Include
                 
                   # Include
                  
                    Using namespace std; int a [20005]; int main () {int n, m; while (cin> n> m & n + m) {string str; map
                   
                     Hp; memset (a, 0, sizeof (a); for (int I = 0; I
                    
                      > Str; hp [str] ++;} map
                     
                       : Iterator it; for (it = hp. begin (); it! = Hp. end (); ++ it) {++ a [it-> second]; // count} for (int I = 1; I <= n; I ++) {cout <
                      

 

Related Article

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.