codeforces C. Functions again】的更多相关文章

Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about…
…… 原题: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried…
题意:给定了一个公式,让你找到一对(l,r),求解出公式给定的F值. 当时没有想到,我把(-1)^(i-l)看成(-1)^i,然后思路就完全错了.其实这道题是个简单的dp+最长连续子序列. O(n)求最长连续子序列代码 ll maxx=, sum=, now=; ; i<n; i++) { //数列1-n sum+=dp1[i]; maxx=max(maxx, sum); ) sum=; } 其实我们可以发现,其实正负是交错的,那么我们只要用两个dp(正负相反)的数组来存,再求一次最长连续子序列…
反着求一遍最大连续子序列(前项依赖) #include <bits/stdc++.h> using namespace std; #define LL long long ; int n; LL dp[MAXN]; LL a[MAXN]; LL Cal(int i) { ]); } int main() { scanf("%d", &n); ; i <= n; i++) scanf("%lld", &a[i]); memset(dp…
codeforces 407 div1 A题(Functions again) Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, the…
链接 codeforces 题解 结论:\(f_0(n)=2^{n的质因子个数}\)= 根据性质可知\(f_0()\)是一个积性函数 对于\(f_{r+1}()\)化一下式子 对于 \[f_{r+1} = \sum_{d|n}f_r(d)\] \(f_r+1\)可以看做\(f_r()\)和\(g(d)\)的狄利克雷卷积因为\(f_0()\)是积性函数,\(g(d)\)也是积性函数,由卷积性质得\(f_{r+1}()\)也是积性函数,那么\(f_r\)同理 对于\(n\)质因数分解得到: \[n=…
Discription Bash got tired on his journey to become the greatest Pokemon master. So he decides to take a break and play with functions. Bash defines a function f0(n), which denotes the number of ways of factoring n into two factors p and q such that …
[题目链接]:http://codeforces.com/problemset/problem/757/E [题意] 给你q个询问; 每个询问包含r和n; 让你输出f[r][n]; 这里f[0][n]是n分解成两个数u,v的乘积的个数; 这里u和v互质; 而f[r][n]当r>0时,有个递推式; [题解] 那个递推式等价于 即n的所有因子x的f[r][x]的和; 这里需要知道; f[0][n]=2n的不同质因子个数 且容易得到 当a和b互质的时候,f[0][a*b]=f[0][a]*f[0][b…
题目链接: http://codeforces.com/contest/757/problem/E?csrf_token=f6c272cce871728ac1c239c34006ae90 题目: 题解: $f_0(n) = 2^{n的不同质因子的个数}$ $ f_r(n) = \sum_{d|n}f_{r-1}(d)$ $f_0$是积性函数 , $f_r = f_0 * Id^r (1) $也是积性函数 , 所以只需要求$f_r(p^k)$就行了 $f_r(p^k)$与p无关 , $f_0(p^…
[题目链接]:http://codeforces.com/contest/789/problem/C [题意] 看式子. [题解] 考虑最后的答案区间; 如果那个区间是从奇数位置的数字开始的; 那么奇数位上的|a[i+1]-a[i]|的系数(-1)^(i-l)就为1否则为-1 如果那个区间是从偶数位置的数字开始的; 那么偶数位-.就为-1; 按照这个规则我们处理出b[i]=|a[i+1]-a[i]| 然后分两类处理 一种是偶数位的b[i]为正,奇数位的为负; 另一种是奇数位...负....正 然…