HDU 1800 string Hash bare topic

Source: Internet
Author: User

Test instructions: It means that there are several pilots that need to practice flying on a broom, each with a different grade, and a high-level pilot who can be the teacher of a low-level pilot, and each pilot has at most and only one teacher and student. Pilots with teacher-student relationships can practice on the same broom, and this nature is transitive. That is, for example have a,b,c,d,e five pilots, and grade is a>b>c>d>e, then can make a when B's teacher, b when C's teacher, E when D's teacher, then a,b,c can practice on the same broom, d,e on the same broom practice, so need 2 broom , and if is a teacher of B, b when the teacher of C, c when the teacher of D, D when the teacher of E, then only need a broom. The number of brooms required for the topic is the minimum.

#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include < cmath> #include <vector> #include <queue> #include <stack> #include <map> #include < algorithm> #include <set>using namespaceStd;typedefLong Longll;typedefunsigned long longUll;#define MM (A, B) memset (A,b,sizeof (a));ConstDoubleEps =1e-10;ConstintInf =0x7f7f7f7f;ConstDoublePi=ACOs(-1);ConstintMaxn= -+ +;CharS[ Max];intHash[4000];intBkdrhash(Char*S){Long LongSeed=131;Long LongHashv=0; while(*S==' 0 ')S++; while(*S) {Hashv=Hashv*Seed+(*S++); }return (Hashv&0x7FFFFFFF);}intMain(){intN; while(~scanf("%d",&N)) { for(intI=1;I<=N;I++) {scanf('%s ',S);Hash[I]=Bkdrhash(S); }Sort(Hash+1,Hash+N+1);intAns=1,Tmp=1; for(intI=2;I<=N;I++) {if(Hash[I]==Hash[I-1])Tmp++;ElseTmp=1;Ans=Max(Ans,Tmp); }Printf("%d\n",Ans); }return0;}

Analysis: Just find out the number of occurrences of the most repeated occurrences

HDU 1800 string Hash bare topic

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.