[ CodeForces 438 D ] The Child and Sequence】的更多相关文章

\(\\\) \(Description\) 维护长为 \(N\) 的数列,\(M\)次操作,支持单点修改,区间取模,查询区间和. \(N,M\le 10^5\) \(\\\) \(Solution\) 线段树单点修改直接改,直接维护区间和就好. 关于取模,显然的优化是,当前节点代表区间最大值如果小于模数就停止递归. 事实上我们只需要这样做,甚至连区间取模的 tag 都不用. 因为一个数变为 \(1\) 至多需要 \(log\) 次取模,所以每个数至多被有效操作 \(log\) 次,然而修改是单…
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 to repair the sequence. Initi…
[原题题面]传送门 [大致题意] 给定一个长度为n的非负整数序列a,你需要支持以下操作: 1:给定l,r,输出a[l]+a[l+1]+…+a[r]. 2:给定l,r,x,将a[l],a[l+1],…,a[r]对x取模. 3:给定k,y,将a[k]修改为y. [数据范围] n,m<=100000,a[i],x,y<=109. [题解大意] 维护最大值和区间和,然后通过最大值有没有超过x来判断需不需要取模操作. [code] #include<bits/stdc++.h> using…
题目 首先令\(f_i\)表示权值和为\(i\)的二叉树数量,\(f_0=1\). 转移为:\(f_k=\sum_{i=0}^n \sum_{j=0}^{k-c_i}f_j f_{k-c_i-j}\) 令多项式\(D=\sum_{i=0}^m [i在c中出现过]x^i\),\(F(x)为f的普通生成函数\),根据转移式发现F其实等于F卷积上F再卷积上D,再加上一个1,因为转移式转移不到\(f_0\). 所以 \[\begin{align} F&=F^2D+1\\ DF^2-F+1&=0\\…
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 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…
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…
D - The Child and Sequence 思路: 因为有区间取模操作所以没法用标记下传: 我们发现,当一个数小于要取模的值时就可以放弃: 凭借这个来减少更新线段树的次数: 来,上代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 100005 #define ll lo…
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…