树状数组模块 ACM个人模板 POJ 2155 题目测试通过 /** * 树状数组模块 * 下标从0开始 */ typedef long DG_Ran; typedef long DG_Num; const DG_Num DG_MAXN = 1005; //2^n DG_Num LowBit(DG_Num n) { return n & (-n); } //获取父节点索引 DG_Num DGFather(DG_Num n)

/** * 线性筛法求素数表 * 复杂度: O(n) */ const long MAXP = 1000000; long prime[MAXP] = {0},num_prime = 0; int isNotPrime[MAXP] = {1, 1}; void GetPrime_Init()//初始化调用 { for(long i = 2 ; i < MAXP ; i ++) { if(!

又是我们的OJ 题目链接: http://www.cn210.com/onlinejudge/problemshow.php?pro_id=92 Description tancu likes space travels but he is a poor software developer and will never be able to buy his own spacecraft. That is why he is preparing to steal the spacecraft of Petru. There is only one problem - Petru has locked the spacecraft with a sophisticated cryptosystem based on the ID numbers of the stars

http://www.cn210.com/onlinejudge/problemshow.php?pro_id=98 我们的OJ Description &nbsp;</center> Input The next line contains the numbers of&nbsp;S:&nbsp;x1,&nbsp;x2, ...,&nbsp;xn.&nbsp; It is known that each&nbsp;xi&nbsp;is an integer, 0 &le;&nbsp;xi&nbsp;&le; 2*109.&nbsp; The input data set is correct and ends with an end of file.&nbsp;</div> Output &nbsp; Sample Input 2 1 2 3 1 3 9 4 1 2 3 6 Sample Output 1 12 4 首先由于行列式交换

题目链接: http://acm.pku.edu.cn/JudgeOnline/problem?id=2976 0-1分数规划 最优比例生成树 迭代法 证明:(前几次都是看别人的,这次自己证明) 对于集合s,令l* = max{ a(x) / b(x) } = a(x*) / b(x*).l为

链接: http://acm.pku.edu.cn/JudgeOnline/problem?id=1141 题目意思是输入一些括号,补充括号使之成为没有错误的括号就是只能有括号组在括号组里面,不能出现([)]或者([)]一类的情况 方法是DP

这道题是我专门为了了解和学习树状数组而写的 这题用树状数组记录翻转次数,然后mod一个2,也可以不断地取反 还要用到二维的树状数组.于是我专门写

/** * Hash模板 * Based: 0 * template<unsigned long _SZ,class _T, unsigned long *pFun(_T _Off)> * class _My_Hash_ToInt * 传入数据大小_SZ,传入类型_T,Hash函数 * 传入类型_T必须重载 = 和 == 符号 * 收录了ELF

题目: http://acm.hdu.edu.cn/showproblem.php?pid=3336 水题一道,主要是测试数据很水 不解释,贴代码: #include <iostream> #include <cstdio> #include <vector> #include <cstring> using namespace std; char str[200005]; vector<long>glo_Pos; int main() { int t; long output,i,n,j; scanf("%d",&t); while(t --) { output = 0; glo_Pos.clear(); scanf("%ld %s", &n, str); for(i = 0; i < n; i ++) { if(str[i] ==