博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
以前刷过的FFT
阅读量:6534 次
发布时间:2019-06-24

本文共 3500 字,大约阅读时间需要 11 分钟。

2017-2018 ACM-ICPC, Asia Daejeon Regional Contest

#include
using namespace std;#define maxn 4000005const double pi=acos(-1.0);struct com{ double x,y; com(double X=0,double Y=0) { x=X,y=Y; }}a[maxn],b[maxn];com operator + (com a,com b) {
return com(a.x+b.x,a.y+b.y);}com operator - (com a,com b) {
return com(a.x-b.x,a.y-b.y);}com operator * (com a,com b) {
return com(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);}int S,T,n,m,L,R[maxn],ans[maxn];long long F[maxn];char s[maxn],t[maxn];double f[maxn],g[maxn];void FFT(com a[maxn],int opt){ for (int i=0;i
>1]>>1)|((i&1)<<(L-1)); for (int i=0;i

 模仿这个题目在TOJ出了一个题,还无人AC 

Fuzzy Search

 

Leonid works for a small and promising start-up that works on decoding the human genome. His duties include solving complex problems of finding certain patterns in long strings consisting of letters 'A', 'T', 'G' and 'C'.

Let's consider the following scenario. There is a fragment of a human DNA chain, recorded as a string S. To analyze the fragment, you need to find all occurrences of string T in a string S. However, the matter is complicated by the fact that the original chain fragment could contain minor mutations, which, however, complicate the task of finding a fragment. Leonid proposed the following approach to solve this problem.

Let's write down integer k ≥ 0 — the error threshold. We will say that string Toccurs in string S on position i (1 ≤ i ≤ |S| - |T| + 1), if after putting string Talong with this position, each character of string T corresponds to the some character of the same value in string S at the distance of at most k. More formally, for any j (1 ≤ j ≤ |T|) there must exist such p (1 ≤ p ≤ |S|), that |(i + j - 1) - p| ≤ k and S[p] = T[j].

For example, corresponding to the given definition, string "ACAT" occurs in string "AGCAATTCAT" in positions 2, 3 and 6.

Note that at k = 0 the given definition transforms to a simple definition of the occurrence of a string in a string.

Help Leonid by calculating in how many positions the given string T occurs in the given string S with the given error threshold.

Input

The first line contains three integers |S|, |T|, k (1 ≤ |T| ≤ |S| ≤ 200 000, 0 ≤ k ≤ 200 000) — the lengths of strings S and T and the error threshold.

The second line contains string S.

The third line contains string T.

Both strings consist only of uppercase letters 'A', 'T', 'G' and 'C'.

Output

Print a single number — the number of occurrences of T in S with the error threshold k by the given definition.

Examples

Input
10 4 1 AGCAATTCAT ACAT
Output
3

Note

If you happen to know about the structure of the human genome a little more than the author of the problem, and you are not impressed with Leonid's original approach, do not take everything described above seriously.

 

#include
using namespace std;typedef double db;const db PI=acos(-1.0);struct Complex{ db x,y; Complex(db _x=0.0,db _y=0.0):x(_x),y(_y){} Complex operator + (const Complex &b)const { return Complex(x+b.x,y+b.y); } Complex operator - (const Complex &b)const { return Complex(x-b.x,y-b.y); } Complex operator * (const Complex &b)const { return Complex(x*b.x-y*b.y,x*b.y+y*b.x); }};void change(Complex y[],int len){ for(int i=1,j=len/2;i
=k) { j-=k; k/=2; } if(j
0); for(int i=0;i

 

转载于:https://www.cnblogs.com/BobHuang/p/9457315.html

你可能感兴趣的文章
洛谷.4180.[模板]次小生成树Tree(Kruskal LCA 倍增)
查看>>
TCL函数“参数自动补全” 与 “help 信息显示”
查看>>
汇编基础--标识符、标号、伪指令和指令
查看>>
Linux软中断、tasklet和工作队列
查看>>
Asp.Net Core 轻松学-利用日志监视进行服务遥测
查看>>
LightSwitch社区资源搜集
查看>>
Android通讯录查询篇--ContactsContract.Data 二(续)
查看>>
IT人的自我导向型学习:开篇杂谈
查看>>
[原创]BizTalk动手实验系列目录
查看>>
HDU 4611Balls Rearrangement(思维)
查看>>
[LeetCode] Majority Element II
查看>>
minGW, cygwin, GnuWin32【C++的跨平台交叉编译问题】
查看>>
我的Dll(动态链接库)学习笔记(转)
查看>>
应用程序域
查看>>
有向图的拓扑排序算法JAVA实现
查看>>
HTML页面跳转的5种方法
查看>>
Android获取当前时间与星期几
查看>>
jenkins2 multibranch
查看>>
Css定位-定位
查看>>
am335x 电容屏驱动添加。
查看>>