hdu 4267】的更多相关文章

A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4996    Accepted Submission(s): 1576 Problem Description Let A1, A2, ... , AN be N elements. You need to deal with…
http://acm.hdu.edu.cn/showproblem.php?pid=4267 [思路] 树状数组的区间修改:在区间[a, b]内更新+x就在a的位置+x. 然后在b+1的位置-x 树状数组的单点查询:求某点a的值就是求数组中1~a的和. (i-a)%k==0把区间分隔开了,不能直接套用树状数组的区间修改单点查询 这道题的K很小,所以可以枚举k,对于每个k,建立k个树状数组,所以一共建立55棵树 所以就可以多建几棵树..然后就可以转换为成段更新了~~ [AC] #include<b…
题意:给一个序列,操作1:给区间[a,b]中(i-a)%k==0的位置 i 的值都加上val  操作2:查询 i 位置的值 解法:树状数组记录更新值. 由 (i-a)%k == 0 得知 i%k == a%k,又因为k <= 10,想到建55棵树状数组,即对每个(k,x%k)都建一棵树状数组,每次更新时,在第(k,a%k)棵树状数组上更新a这个点,更新值为val,然后再b+1处更新值为-val,即在[a,b]内更新了val. 查询pos的时候,求出每一个树状数组(k,pos%k)的sum值即可.…
题意:有一个序列 "1 a b k c" means adding c to each of Ai which satisfies a <= i <= b and (i - a) % k == 0. (1 <= a <= b <= N, 1 <= k <= 10, -1,000 <= c <= 1,000)"2 a" means querying the value of Aa. (1 <= a <=…
A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4032    Accepted Submission(s): 1255 Problem Description Let A1, A2, ... , AN be N elements. You need to deal with…
A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5339    Accepted Submission(s): 1693 Problem Description Let A1, A2, ... , AN be N elements. You need to deal with…
思路:先dfs一下,找出1,n间的路径长度和价值,回溯时将该路径长度和价值清零.那么对剩下的图就可以直接树形dp求解了. #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #define inf 100000000 #define Maxn 110 using namespace std; ],e,n,T,a[Maxn],len,sum; struct Edge…
一个很不错的题: 刚刚看到这个题目就感觉要用线段树或者树状数组,但是有感觉有点不同: 敲了一发简单的线段树之后果断的T了: 网上一搜题解,发现要用55颗线段树或者树状数组: 一共有k种树,然后每种树根据他们%k的余数的不同又分成好几颗: 然后最后统计的时候只要对每个节点统计这k种树种的信息就行: #include<cstdio> #include<cstring> #define maxn 50005 using namespace std; ][maxn],num[maxn];…
Problem Description Doctor Ghee is teaching Kia how to calculate the sum of two integers. But Kia is so careless and alway forget to carry a number when the sum of two digits exceeds 9. For example, when she calculates 4567+5789, she will get 9246, a…
题意: n个数字 下面n个数字表示数列 2个操作 1 [u, v]  k  add [u,v ]区间 (u点要计算)每隔k个位置,该数字+add 2 pos 询问 pos下标的值(下标从1开始) 思路: 因为k很小, 可以直接存 k[11] 注意查询时, 先找到 pos 所在的 叶子节点 再向上 添加 对应k位置的值 #include<iostream> #include<stdio.h> #include<algorithm> #include<string&g…