Question
Next comes the basic usage of string
// Less than 30 digits // The level length is even greater than int64, so it should be simulated using a string, then note that removing the leading zero // The maximum number of duplicates is the answer // The addition of the string modification # include <cstdio> # include <iostream> # include <cstring> # include <algorithm >#include <string> using namespace STD; int main () {int N; char s [35]; while (scanf ("% d", & N )! = EOF) {string ss [3010]; for (INT I = 0; I <n; I ++) {scanf ("% s", S ); int L = strlen (s); int id = 0; For (Int J = 0; j <L; j ++) {If (s [J]! = '0') break; Id ++;} For (Int J = ID; j <L; j ++) {ss [I] + = s [J] ;}} sort (SS, SS + n); int ans = 1; int Maxx = 1; for (INT I = 1; I <n; I ++) {If (ss [I] = ss [I-1]) ans ++, Maxx = max (Maxx, ANS ); else ans = 1;} printf ("% d \ n", Maxx);} return 0 ;}
View code