期望得分:100+60+0=160

 实际得分:100+30+0=130

 

2017北京国庆刷题Day3 morning

考场上用的哈希

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define mod 1000003
#define mod2 100003
char s[10000001];
bool vis[mod],vis2[mod2];
int hash1,hash2;
int gethash()
{
    int len=strlen(s);
    sort(s,s+len);
    hash1=s[0]-'A'+1,hash2=hash1;
    for(int i=1;i<len;i++)
    {
        hash1=(hash1*26+(s[i]-'A')+1)%mod;
        hash2=(hash2*26+(s[i]-'A')+1)%mod2;
    }
}
int main()
{
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    int n,ans=0;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%s",s);
        gethash();
        if(!vis[hash1] || !vis2[hash2]) vis[hash1]=true,vis2[hash2]=true,ans++; 
    }
    printf("%d",ans);
}
myself

相关文章:

  • 2022-02-04
  • 2021-07-14
  • 2021-12-11
  • 2022-02-08
  • 2021-07-30
  • 2022-02-11
  • 2021-08-23
  • 2022-02-24
猜你喜欢
  • 2021-10-25
  • 2021-12-02
  • 2022-02-13
  • 2021-10-29
  • 2021-11-04
  • 2021-11-13
  • 2021-10-12
相关资源
相似解决方案