zoukankan      html  css  js  c++  java
  • Codeforces Beta Round #7

    A题,应该是水题,我没看懂。。。

    B题,这题很多坑,注意x是LL,而且x = 0的情况,所以初始化要为-1,最后这题是内存管理啊。。操作系统学的不好,题意读不懂啊。

    申请内存的时候,是从头找 如果这一段的长度>=申请的,就可以申请内存。调整什么的,删除应该比较好理解。

    C题,以前做过,扩展欧几里德,基本问题。

    D题,前缀回文串,自己写了个bfs判断0-i是回文串,果断超时了。。然后看别人用非常简单的哈希办法,给A了。。

    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <algorithm>
    #include <cstring>
    #include <map>
    #include <vector>
    #include <queue>
    using namespace std;
    #define LL __int64
    int dp[5000001];
    char str[5000001];
    int main()
    {
        int i,len,ans;
        unsigned int l = 0,r = 0,t = 1,num = 99;
        scanf("%s",str);
        len = strlen(str);
        ans = 0;
        for(i = 0;i < len;i ++)
        {
            l = l*num + (str[i]-'a');
            r = r + t*(str[i]-'a');
            t *= num;
            if(l == r) dp[i] = dp[(i-1)/2] + 1;
            ans += dp[i];
        }
        printf("%d
    ",ans);
        return 0;
    }
    View Code
  • 相关阅读:
    续上-选课系统
    第一个java web的课堂练习-开始
    子类与父类方法间的关系
    课后作业-3
    小结
    Java中子类与基类变量间的赋值
    今日总结
    今日总结
    今日总结
    今日总结
  • 原文地址:https://www.cnblogs.com/naix-x/p/3674009.html
Copyright © 2011-2022 走看看