半天了,此题自己想个暴力法,果断超时,,,,,,,,
照别人copy,后过。。。。。。。
最恨别人忽略水牛,比电脑崩了资料没备份更令人痛心!!!
其实又能怎样呢?天生大脑CPU为低频,内存为512的人,又怎样才能力挽狂澜?有人说:虽然低频,但是输出功率还是看具体使用啊!
一派胡言!!!不要总拿龟兔赛跑来欺骗小孩子!!!不是所有的兔子都是懒的,任你乌龟怎样,兔子也是轻松超越!!!
不扯了!!!
贴代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include <iostream> #include <cstring> #include <cstdio> using namespace std; int next[200005]; char st[200005]; int p[200005],m,n; void getNext() { int j=-1,i=0; next[0]=-1; while (i<m) { if (j==-1||st[i]==st[j]) { j++; i++; next[i]=j; } else j=next[j]; } } int main() { int i,j,t,n; int sum,data; scanf ( "%d" ,&n); while (n--) { sum=0; memset (p,0, sizeof (p)); scanf ( "%d" ,&m); scanf ( "%s" ,st); getNext(); for ( int i=1;i<=m;i++) { p[i]=(p[next[i]]+1)%10007; sum=(sum+p[i])%10007; } cout<<sum<<endl; } return 0; } |
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步