zoukankan      html  css  js  c++  java
  • 字符串模拟赛T1

    // source code from laekov for c0x17
    #define PRID "bxjl"
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    
    using namespace std;
    
    typedef long long dint;
    
    const int maxn = 100003;
    const int mod = 998244353;
    
    char a[maxn];
    int n, m, ne[maxn], sz[maxn];
    
    void preNext() {
        ne[1] = 0;
        for (int i = 2, j = 0; i <= n; ++ i) {
            for (; j && a[i] != a[j + 1]; j = ne[j]);
            if (a[i] == a[j + 1] && j + 1 < i) {
                ne[i] = ++ j;
            } else {
                ne[i] = 0;
            }
        }
        memset(sz, 0, sizeof(sz));
        for (int i = n; i; -- i) {
            ++ sz[i];
            sz[ne[i]] += sz[i];
        }
    }
    
    int main(int argc, char* args[]) {
        if (argc < 2 || strcmp(args[1], "-nf")) {
            freopen(PRID ".in", "r", stdin);
            freopen(PRID ".out", "w", stdout);
        }
        scanf("%s", a + 1);
        n = strlen(a + 1);
        preNext();
        dint ans(0);
        for (int i = 1; i <= n; ++ i) {
            ans += sz[i];
        }
        printf("%d
    ", (int)(ans % mod));
    }
  • 相关阅读:
    AOP概述
    AOP-动态代理
    IOC容器和Bean的配置
    Spring框架概述
    异常
    Optional 类
    Stream API
    方法引用(Method References)
    函数式(Functional)接口
    stm8笔记1-搭建工程+孤独的小灯闪烁
  • 原文地址:https://www.cnblogs.com/hyfer/p/5689470.html
Copyright © 2011-2022 走看看