| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:memmove(line + 1, line, n);是什么意思呢?见识少了In Reply To:。。。。为什么能过官方数据+uva数据的程序在这里wa,难道是我的rp出了问题? Posted by:Maximum at 2005-08-04 16:57:20 > #include <stdio.h>
> #include <string.h>
>
> const int MAX = 1000000+10;
>
> char line[MAX];
> int n, nextval[MAX];
>
> main() {
> // freopen("10298.in", "r", stdin);
> // freopen("10298.out", "w", stdout);
>
> while (gets(line) && strcmp(line, ".")) {
> n = strlen(line);
> memmove(line + 1, line, n);
>
> int i, pos;
> pos = nextval[1] = 0;
> for (i = 2; i <= n; i++) {
> while (pos && line[pos + 1] != line[i])
> pos = nextval[pos];
> if (line[pos + 1] == line[i]) pos++;
> nextval[i] = pos;
> }
>
> int sub = n - nextval[n], ans;
> if (n % sub == 0) ans = n / sub;
> else ans = n;
>
> printf("%d\n", ans);
> }
>
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator