Hust oj 2060 擷取方案數(KMP)

2021-07-22 09:56:49 字數 1092 閱讀 3881

擷取方案數

time limit: 1000 ms

memory limit: 32768 k

total submit: 189(76 users)

total accepted: 75(64 users)

rating:

special judge: no

description

給定乙個模式串t,主串s,問:從s中擷取t有多少種方案?

input

有多組測試資料,對於每組測試資料,第一行是模式串t,第二行是主串s,資料中僅包含大小寫字母和數字,模式串t長度不超過10^4, 主串s長度不超過10^5。

注意:資料是隨機的。

output

對於每組測試資料,輸出一行,為擷取方案數。

sample input

abc

abcdaabcab

abcd

abcdaabcab

abaabababa

sample output

2

13

kmp稍微改一下。。。
#include#include#include#includeusing namespace std;

const int maxn = 100005;

const int inf = 0x3f3f3f;

int next[maxn];

char a[maxn];

char b[maxn];

int len_a,len_b;

int pos;

int t;

void get_next(char *b,int *next) //獲得next陣列

else

j = next[j];//否則回溯到合適位置

}}int kmp(char *a,char *b)

else

j = next[j]; // 否則回溯到合適位置

if(j == len_b)

}return sum;

}int main()

}

Hust oj 1151 追求 暴力)

追求 time limit 1000 ms memory limit 65536 k total submit 236 61 users total accepted 54 47 users rating special judge no description 經歷了那晚的竹林深處相識後靜竹對數學...

HUSTOJ實現的相關想法

這兩天通過讀 hustoj 的原始碼,是我對oj系統有了初步的了解,對整個系統的構架有了淺薄的認識。拿hustoj來講,hustoj的結構是典型的lamp伺服器,就是linux apache mysql php,以及用c c寫的評測機核心。hustoj有兩種資料互動的模式,兩種的不同點在於,是評測機...

標緻206配置

基本引數 標緻206 1.6 xr mt 標緻206 1.6 xr at 標緻206 1.6 xt mt 標緻206 1.6 xt at 最低價 8.68萬 86800 9.78萬 97799 9.78萬 97799 10.88萬 108800 發動機 1.6l 106馬力 l4 1.6l 106馬...