1. Title Description
It's a very simple question , Given $n$ A large integer , Find the maximum number of occurrences .
2. The basic idea
This problem can be done with hash ,ELFHash Wait for hash to pass .
3. Code
/* 1800 */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000") #define sti set<int>
#define stpii set<pair<int, int> >
#define mpii map<int,int>
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define rep(i, a, n) for (int i=a;i<n;++i)
#define per(i, a, n) for (int i=n-1;i>=a;--i)
#define clr clear
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define lson l, mid, rt<<1
#define rson mid+1, r, rt<<1|1 const int maxl = ;
const int MOD = ;
int H[MOD], cnt[MOD];
char s[maxl];
int n, ans; inline int ELFHash(char *s) {
unsigned int h = ;
unsigned int g;
int i = ; while (s[i]) {
h = (h<<) + s[i];
g = h & 0xf0000000L;
if (g) {
h ^= (g >> );
h &= ~g;
}
++i;
} return h & 0x7fffffff;
} inline void Hash(char *s) {
int i = ; while (s[i]=='') ++i;
int k = ELFHash(s+i);
int t = k % MOD; while (H[t]!=- && H[t]!=k)
t = (t + ) % MOD; if (H[t] == -) {
cnt[t] = ;
H[t] = k;
} else if (++cnt[t] > ans) {
ans = cnt[t];
}
} int main() {
ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif while (scanf("%d",&n)!=EOF) {
memset(H, -, sizeof(H));
ans = ;
rep(i, , n) {
scanf("%s", s);
Hash(s);
}
printf("%d\n", ans);
} #ifndef ONLINE_JUDGE
printf("time = %d.\n", (int)clock());
#endif return ;
}
【HDOJ】1800 Flying to the Mars More articles about
- Hang Dian 1800 Flying to the Mars( greedy )
http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/Oth ...
- HDU 1800——Flying to the Mars——————【 String hash 】
Flying to the Mars Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDOJ.1800 Flying to the Mars( greedy +map)
Flying to the Mars Let me challenge the topic Problem analysis Yes n personal , Everyone has a certain level , High level people can teach low level people to ride brooms , And they can share a broom , Ask at least a few brooms . This problem is different from the minimum interception system ...
- hdu 1800 Flying to the Mars
Flying to the Mars The question : Find the least increasing sequence of questions ( Strictly increasing ) The number of , Each number in the sequence is not more than 30 position : The length of the sequence is not longer than 3000: input: 4 (n) 10 20 30 04 ou ...
- HDU - 1800 Flying to the Mars 【 greedy 】
Topic link http://acm.hdu.edu.cn/showproblem.php?pid=1800 The question give N Individual level then high level Of people It's portable Lower than him level People who ...
- HDOJ 1800 Flying to the Mars Blind search ......................so easy...........
check the original problem here:http://acm.hdu.edu.cn/showproblem.php?pid=1800 the AC code: #include ...
- 【HDOJ】4729 An Easy Problem for Elfness
In fact, it is to find the data between paths on the tree K Big topic . Decisive chairman tree + LCA. The initial traffic is the minimum on this path . if a<=b, Obviously directly for s->t establish pipe It can optimize the flow : otherwise , Yes [0, 10**4] Two points to get ...
- --hdu 1800 Flying to the Mars( greedy )
Topic link :http://acm.hdu.edu.cn/showproblem.php?pid=1800 Ac code: #include<stdio.h> #include<std ...
- 【HDOJ】【3506】Monkey Party
DP/ Quadrilateral inequality Naked topic ring stone merge …… It's just a chain //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...
Random recommendation
- Resume generation platform project development -STEP1 Questionnaire design
At the end of the course on Friday , Team building QQ Groups and wechat groups , Start talking about the project . The general idea at the beginning : Employment information platform , Collect enterprise recruitment information and employment information , It provides a school enterprise docking platform for students and enterprises . Later I found that Tan Zhuo also had a related idea , After discussion ...
- SSIS example —— take SQL The information obtained is transmitted to Email in
Recently, I encountered a technical problem in developing an email notification for corporate finance . So I designed SSIS What's important is that every day ERP After the system payment data is exported to the financial payment platform Email Inform Finance , Then the finance department will pay on the payment platform . Because the development time was very long at that time ...
- 20145208 GDB Debug assembly stack process analysis
20145208 GDB Debug assembly stack process analysis Test code #include<stdio.h> short addend1 = 1; static int addend2 = 2; const ...
- The finger of the sword offer: Daheng image
Daheng image : Founded on 1991 year , Focus on visual components . Research and development of vision system and internet medical related products . High tech enterprises for production and marketing . Product information : 1. Image capture card The analog image signal input by the camera passes through A/D transformation , Or the output of the digital camera ...
- matlab2015b Call the camera
Reference link :http://blog.csdn.net/lyqmath/article/details/7307429 My computer is Acer T5000 Calling code : % By lyqmathclc; clear ...
- ElasticSearch.js
ElasticSearch It's based on Lucene Search server for . It provides a distributed multi-user capability of full-text search engine , be based on RESTful web Interface .Elasticsearch Yes, it is Java Developed , And as a Apach ...
- php Error message configuration
display_errors = on/off Error echo , The development mode of common language , But many applications forget to turn off this option in the formal environment . Error echo can expose a lot of sensitive information , Facilitate the attacker's next attack . It is recommended to turn off this option . ...
- 0627 CMD function php Code
open cmd: How to run in this php Code 1. Adjust environment variables : Right click on the computer -> attribute -> Advanced system setup -> environment variable 2. New environment variable : The user variables in the upper section ----- Variable name :PHP_HOME ...
- dom Method reading xml( Not commonly used )
Book.java package com.xml.demo; public class Book { private int id; private String name; private Flo ...
- Python3 Debugging skills —— Dead cycle
Under the said Python3 Don't use gdb Self debugging of Antecedents feed : The server is stuck for no reason , Use the Internet method to use gdb, Downloaded a lot of components , Including that libpython.py, It's no use , You can't see the stack , Also tried to save core Documents, etc. I'm looking for an official ...