1200

  1. #include<iostream>
  2. usingnamespacestd;
  3. __int64hash[1000000]={0};
  4. __int64key;
  5. __int64total;
  6. chartext[1600008];
  7. intnum(0);
  8. constintprime=999983;
  9. voidfac(intk)
  10. {
  11. if(!hash[k])
  12. {
  13. hash[k]=total;
  14. num++;
  15. }
  16. else
  17. {
  18. if(hash[k]==total)
  19. return;
  20. else
  21. fac((k+1)%prime);
  22. }
  23. }
  24. intmain()
  25. {
  26. //freopen("in.txt","r",stdin);
  27. intN,NC,l,i,j;
  28. scanf("%d%d",&N,&NC);
  29. getchar();
  30. scanf("%s",text);
  31. l=strlen(text);
  32. for(i=0;i<=l-N;i++)
  33. {
  34. key=0;
  35. total=0;
  36. for(j=i;j<i+N;j++)
  37. {
  38. total+=text[j];
  39. total*=26;
  40. }
  41. key=total%prime;
  42. fac(key);
  43. }
  44. cout<<num<<endl;
  45. return0;
  46. }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值