本文共 1397 字,大约阅读时间需要 4 分钟。
1 /* QYP kuai wo dai ma*/ 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #define rep(i,a,b) for(register int i=a;i<=b;i++)15 #define ll long long16 #define re register17 using namespace std;18 const int N=1e6;19 int w[N+10];20 int n,a,b,L,R;21 char s[N+10],t[N+10];22 int nxt[N+10];23 inline int gi() {24 re int res=0;25 char ch=getchar();26 while(ch<'0'||ch>'9') ch=getchar();27 while(ch>='0'&&ch<='9') res=res*10+ch-'0',ch=getchar();28 return res;29 }30 void get_w() {31 w[1]=b;32 for(re int i=2;i<=n;i++) w[i]=(w[i-1]+a)%n;33 }34 void get_s() {35 for(re int i=1;i<=n;i++) {36 if(w[i]>=L&&w[i]<=R) {37 if(w[i]%2==0) s[i]='A';38 else s[i]='T';39 }40 else {41 if(w[i]%2==0) s[i]='G';42 else s[i]='C';43 }44 }45 }46 void NEXT() {47 int len=strlen(t+1);48 nxt[1]=0;49 int j=0;50 for(re int i=2;i<=len;i++) {51 while(j&&t[j+1]!=t[i]) j=nxt[j];52 if(t[j+1]==t[i]) nxt[i]=++j;53 }54 }55 void KMP() {56 int lens=strlen(s+1),j=0;57 int lent=strlen(t+1);58 int ans=0;59 for(re int i=1;i<=lens;++i) {60 while(j&&t[j+1]!=s[i]) j=nxt[j];61 if(t[j+1]==s[i]) ++j;62 if(j==lent) {ans++;j=nxt[j];}63 }64 cout<
转载于:https://www.cnblogs.com/ypz999/p/6883175.html