To find the time limit for a cloned person: +Ms | Memory Limit:65535KB Difficulty:3
-
-
Describe
-
A small town in the United States was recently attacked by aliens and some residents were taken away and cloned, and now scientists have extracted DNA from some people in the town, identifying the number of DNA with the same number of clones, such as the following 9 sequences
Aaaaaa
Acacac
Gttttg
Acacac
Gttttg
Acacac
Acacac
Tccccc
Tccccc
Where TCCCCC,GTTTTG have two identical individuals, ACACAC have four, aaaaaa is one, then the number of rows corresponding to the output
First row 1, second row 2, fourth row 1, other row output 0, total 9 rows
-
-
Input
-
-
number of sequences not exceeding 20000, no more than 20 characters per sequence
Input ends at 0 0
-
-
Output
-
-
the output can be described in title
-
-
Sample input
-
-
9 6AAAAAAACACACGTTTTGACACACGTTTTGACACACACACACTCCCCCTCCCCC0 0
-
-
Sample output
-
-
120100000
-
-
code:
-
-
#include <stdio.h> #include <stdlib.h> #include <string.h>int cmp (const void *a,const void *b) {return ( strcmp ((char*) A, (char*) b)); int main () {int M,n,i,num[20005];char str[20002][21];while (scanf ("%d%d", &m,&n)!=eof&&m!=0& &n!=0) {for (i=0;i<m;i++) scanf ("%s", Str[i]), Qsort (str,m,sizeof (str[0)), CMP), memset (num,0,sizeof (num)); int Count=1;for (i=1;i<=m;i++) {if (strcmp (str[i],str[i-1]) ==0) count++;else{num[count]++;count=1;}} for (i=1;i<=m;i++) printf ("%d\n", Num[i]);} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Looking for clones.