D. The Child and Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/problem/D Description At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important…
D. The Child and Sequence   At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite sequence of Picks. Fortunately, Picks remembers how t…
题目链接:http://codeforces.com/problemset/problem/438/D 给你n个数,m个操作,1操作是查询l到r之间的和,2操作是将l到r之间大于等于x的数xor于x,3操作是将下标为k的数变为x. 注意成段更新的时候,遇到一个区间的最大值还小于x的话就停止更新. #include <iostream> #include <cstdio> #include <cstring> using namespace std; typedef __…
D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of…
D. The Child and Sequence time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of…
题目链接:http://codeforces.com/contest/474/problem/F 题意简而言之就是问你区间l到r之间有多少个数能整除区间内除了这个数的其他的数,然后区间长度减去数的个数就是答案. 要是符合条件的话,那这个数的大小一定是等于gcd(a[l]...a[r]). 我们求区间gcd的话,既可以利用线段树性质区间递归下去然后返回求解,但是每次查询是log的,所以还可以用RMQ,查询就变成O(1)了. 然后求解区间内有多少个数的大小等于gcd的话,也是利用线段树的性质,区间递…
C. Day at the Beach Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599/problem/C Description One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unab…
题目地址:http://codeforces.com/contest/474/problem/F 由题意可知,最后能够留下来的一定是区间最小gcd. 那就转化成了该区间内与区间最小gcd数相等的个数.区间最小gcd一定小于等于区间最小值.所以仅仅要先推断最小值是否是最小gcd.若是的话,就求出最小值的个数.然后用r-l+1-个数就可以. 对于以上信息.能够用线段树来维护.分别维护区间gcd,区间最小值以及区间最小值的个数. 代码例如以下: #include <iostream> #includ…
题目链接:点击传送 E. Propagating tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Iahub likes trees very much. Recently he discovered an interesting tree named propagating tree. The tree consi…
D. Babaei and Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/D Description As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake. Simple cake is a cylinder of som…