HDU 6186 CS Course 前缀和,后缀和】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6186 题意:给了n个数,然后有q个查询,每个查询要求我们删掉一个数,问删掉这个数后整个序列的与值,或值,异或值的和. 解法: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5+5; int n, m, a[maxn], sum1[maxn][2], sum2[maxn][2], sum3[maxn][2]; int…
[前后缀枚举] #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include<iostream> #include<cstring> #include<set> #include<queue> #include<algorithm> #include<vector> #include<map…
http://acm.hdu.edu.cn/showproblem.php?pid=6186 题意:给出n个数,共有n次询问,每次询问给出一个数p,求除去第p个数后的n-1个数的&.|.^值. 思路:分别计算出&.|.^的前缀和后缀,将前缀和后缀相计算即可. #include<iostream> #include<cstdio> #include<algorithm> using namespace std; ; int n, q; int a[maxn…
保存前缀后缀. 保存一下前缀和后缀,去掉第$i$个位置,就是$L[i-1]$和$R[i+1]$进行运算. #include<bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; int Land[maxn], Rand[maxn]; int Lor[maxn], Ror[maxn]; int Xor; int a[maxn]; int n, p; int main() { while(~scanf("%d%…
CS Course Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 430    Accepted Submission(s): 222 Problem Description Little A has come to college and majored in Computer and Science. Today he has le…
Problem Description Generally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two strings, such as “asdf” and “sdfg”, the result of the addition between them is “asdfg”, for “sdf” is…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6025 Coprime Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 666    Accepted Submission(s): 336 Problem Description Do you know what is…
http://acm.hdu.edu.cn/showproblem.php?pid=1358 Period Problem Description For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string.…
源码:pretopost.cpp #include "stdafx.h" #include <stdio.h> #include <stack> /************************************************************************/ /* 前缀转后缀 */ /************************************************************************…
给一个字符串S,求出所有前缀,使得这个前缀也正好是S的后缀.升序输出所有情况前缀的长度.KMP中的next[i]的意义就是:前面长度为i的子串的前缀和后缀的最大匹配长度.明白了next[i],那么这道题就很容易做了 #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; ; char str[maxn]; int…