摘要:
1 int lowbit(int x) { 2 return x & -x; 3 } 4 5 void change1(int x,int d) //单点修改 6 { 7 for (int i = x; i <= n; i += lowbit(i)) { 8 c[i] += d; 9 } 10 } 11 12 int sum1... 阅读全文
摘要:
问题描述: 给定n个整数(可能有负数)组成的序列a1,a2,...,an,求该序列的最大子段和。如果所有整数都是负数,那么定义其最大子段和为0。 思路: 1.暴力枚举左端点右端点然后求和.O(n^3) 2.预处理前缀和,枚举左端点右端点.O(n^2) 3.类似DP 1 for (int i = 0; 阅读全文
摘要:
题目描述 You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 109+7. Two subsequenc 阅读全文
摘要:
题目描述: There are N stones arranged in a row. The i-th stone from the left is painted in the color Ci.Snuke will perform the following operation zero or 阅读全文