zoukankan      html  css  js  c++  java
  • 哈希

    奇怪的姿势hhh

     1 #include<cstdio> 
     2 #include<cstring>
     3 #include<cmath>
     4 #include<ctime>
     5 #include<iostream>
     6 #include<algorithm>
     7 #include<queue>
     8 #include<set>
     9 #define maxint (2147483647)
    10 #define l(a) ((a)<<1)
    11 #define r(a) ((a)<<1|1)
    12 #define b(a) (1<<(a))
    13 #define mod1 (10000007)
    14 #define mod2 (10000009)
    15 #define rep(i,a,b) for(int i=a;i<=(b);i++)
    16 #define clr(a) memset(a,0,sizeof(a))
    17 typedef long long ll;
    18 typedef unsigned long long ull;
    19 using namespace std;
    20 int readint(){
    21     int t=0,f=1;char c=getchar();
    22     while(!isdigit(c)){
    23         if(c=='-') f=-1;
    24         c=getchar();
    25     }
    26     while(isdigit(c)){
    27         t=(t<<3)+(t<<1)+c-'0';
    28         c=getchar();
    29     }
    30     return t*f;
    31 }
    32 const int maxn=10009,maxm=1509;
    33 int n;
    34 char s[maxn][maxm];
    35 int d1[maxn],d2[maxn];
    36 ull d3[maxn];
    37 int main(){
    38     //freopen("#input.txt","r",stdin);
    39     //freopen("#output.txt","w",stdout);
    40     n=readint();
    41     rep(i,1,n) scanf("%s",s[i]);
    42     rep(i,1,n){
    43         rep(j,0,strlen(s[i])-1){
    44             d1[i]=((d1[i]*107)%mod1+s[i][j])%mod1;
    45             d2[i]=((d2[i]*107)%mod2+s[i][j])%mod2;
    46             d3[i]=d3[i]*107ull+s[i][j];
    47         }
    48     }
    49     int ans=-maxint;
    50     sort(d1+1,d1+n+1);ans=max(ans,int(unique(d1,d1+n+1)-d1-1));
    51     sort(d2+1,d2+n+1);ans=max(ans,int(unique(d2,d2+n+1)-d2-1));
    52     sort(d3+1,d3+n+1);ans=max(ans,int(unique(d3,d3+n+1)-d3-1));
    53     cout<<ans<<endl;
    54     //fclose(stdin);
    55     //fclose(stdout);
    56     return 0;
    57 }
    哈希
  • 相关阅读:
    关于GDI+的图片质量
    断点续传的Demo
    offic2007 ,offic2010安装失败 1935错误处理方案
    Easy Slider幻灯片 API
    Lazyload.js延迟加载效果
    MVC3中 多种跳转方式总结
    MVC中 DropDownList编辑默认选中的使用
    ASP.NET Session的七点认识
    easyui 的datagrid的自适应宽度的问题
    Linux常用文件操作高频使用命令
  • 原文地址:https://www.cnblogs.com/chensiang/p/7850905.html
Copyright © 2011-2022 走看看