Codeforces Beta Round #7

时间:2024-09-18 19:36:14

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[];
char str[];
int main()
{
int i,len,ans;
unsigned int l = ,r = ,t = ,num = ;
scanf("%s",str);
len = strlen(str);
ans = ;
for(i = ;i < len;i ++)
{
l = l*num + (str[i]-'a');
r = r + t*(str[i]-'a');
t *= num;
if(l == r) dp[i] = dp[(i-)/] + ;
ans += dp[i];
}
printf("%d\n",ans);
return ;
}