void search(queue q, int index) { if (q.empty()) return; queue new_q; long long sum = 0; int start_index = n; while (!q.empty()) { result = (result + sum) % mod; int va = q.front(); q.pop();
for (int i = start_index; i > va; i--)
{
if (a[i] == F[index])
{
new_q.push(i);
result++;
sum++;
}
}
start_index = va;
}
search(new_q,index+1);
}
笔试结束了,还是可以的。