SPOJ - DISUBSTR 求串中子串的个数】的更多相关文章

\(height\)简单应用 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<stack> #include<queue> #include<set> #include<map> #define rep(i,j,k) for(register int i=j…
题目链接:pid=1084">点击打开链接 寒假安排 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 128000/64000 KB (Java/Others) SubmitStatistic Next Problem Problem Description 寒假又快要到了,只是对于lzx来说,头疼的事又来了,由于众多的后宫都指望着能和lzx约会呢,lzx得安排好计划才行. 如果lzx的后宫团有n个人.寒假共同拥有m天,而每天仅仅能…
http://acm.hdu.edu.cn/showproblem.php?pid=5384 Problem Description Danganronpa is a video game franchise created and developed by Spike Chunsoft, the series' name is compounded from the Japanese words for "bullet" (dangan) and "refutation&q…
JDOJ 1775: 求N!中0的个数 JDOJ传送门 Description 求N!结果中末尾0的个数 N! = 1 * 2 * 3 ....... N Input 输入一行,N(0 < N < unsigned INT_MAX) Output 输出一行,0的个数 Sample Input 5 Sample Output 1 题解: 求\(\prod_{i=1}^{i=n}\)中末尾0的个数,其实就是在求中\(\prod_{i=1}^{i=n}\)能被几个10整除. 因为\(\prod_{i…
原文 求bit中1的个数有几种做法: - x & (x - 1) - Hamming weight的经典求法,基于树状累加:http://en.wikipedia.org/wiki/Hamming_weight - 内存足够大可以查表得: int bitCount(unsigned int u) {    unsigned int uCount;       uCount = u - ((u >> 1) & 033333333333) - ((u >> 2) &am…
题意: n的阶乘后面有多少个0? 6的阶乘 = 1*2*3*4*5*6 = 720,720后面有1个0.   Input 一个数N(1 <= N <= 10^9) OutPut 输出0的数量 思路: 一个0只能由2*5得到.统计N!中2的个数和5的个数,取少的.即求N!中5的个数.[数论:[N/5]+[N/5^2]+[N/5^3]+[N/5^4]+....]{也自己分析也可以得出此结论} 代码: int main(){ int n; cin >> n; ll ans=0; ll t…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2087 题意:求模式串在主串中出现的次数,与模式串匹配的子串之间不可重叠. 思路:用kmp算法解决,在匹配更新结果后,重新定位模式串时,不可用j = next[j],应该直接让j定位到模式串开头. code: #include <cstdio> #include <cstring> ; char aa[MAXN]; char bb[MAXN]; int next[MAXN]; int l…
题意:给定一个数列,每次查询一个区间不同数的个数. 做法:离线+BIT维护.将查询按右端点排序.从左到右扫,如果该数之前出现过,则将之前出现过的位置相应删除:当前位置则添加1.这样做就保证每次扫描到的某一位置,以该位置为右端点的区间都相应地确定了. /* *Author: Zhaofa Fang *Created time: 2013-08-25-22.29 星期日 */ #include <cstdio> #include <cstdlib> #include <sstre…
DISUBSTR - Distinct Substrings   Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20;Each test case consists of one string, whose length is <= 1000 Output For each test case output one nu…
http://www.spoj.com/problems/SUBST1/en/  题目链接 SUBST1 - New Distinct Substrings no tags  Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20; Each test case consists of one string, whose le…