POJ 1200 Hash
2016-07-16 22:19
302 查看
我的hash从来没写对过。。。。。。。。
(白学了快一年OI ……原来连个hash都没写对过)
但是
但是
今天是一个值得纪念的日子。
看看标题
我竟然在写hash的题解。
(好了好了 废话少说)
题意:
给你一个串,求长度为n的不同的子串的个数。
题目中的NC是什么意思 反正我没看懂,(But我能AC)
思路:
QY讲的hash 随便搞搞就过了。。。
// by SiriusRen #include <bitset> #include <cstdio> #include <cstring> using namespace std; #define N 100000007 bitset<N>b; long long nc,n,ans=0,len,q=0; char a[700000]; int main(){ scanf("%lld%lld\n%s",&n,&nc,a); len=strlen(a); for(int i=0;i<=len-n;i++){ for(int j=0;j<n;j++) q=((q<<8)+a[i+j])%N; if(!b[q])b[q]=1,ans++; q=0; } printf("%lld",ans); }
相关文章推荐
- 洛谷P1111 修复公路
- [备忘]没有为扩展名“.cshtml”注册的生成提供程序
- django初体验 学习笔记
- swift小结01--基础篇
- Codeforces Round #362 (Div. 2)
- Y/N退出选择训练
- 关于SpringMvc中radiobutton默认值为空的问题
- VS2013配置opencv出现msvcp110d.dll丢失问题解决办法
- androidstudio解决Internal error please report to https://code.google.com/p/android/issues
- Android RecyclerView 使用完全解析
- POJ1321 棋盘问题
- AKKA 笔记 - 有限状态机 -2
- pdoner version 0.1.0 release
- Android 事件总线OTTO用法快速入门
- iOS TDD
- Python进阶 学习笔记(三)
- IDEA破解代码
- HDU 5288 OO’s Sequence (from: 2015 Multi-University Training Contest 1)
- 关于Java基础(基本数据类型Float)
- Hibernate 简单使用(四)一对多关联映射