CodeForces 1426F Number of Subsequences】的更多相关文章

题意 给定一个长度为 \(n\) 的串,只包含 abc 和通配符.通配符可以替换 abc 的一个.求所有得到的字符串中子序列 abc 出现的次数,对 \(10^9+7\) 取模. \(\texttt{Data Range:}n\leq 2\times 10^5\) 题解 哇哈哈哈我智商终于恢复了. 比较套路,但其实这个东西我一开始是用类似于期望的东西来想的. 记通配符的数量为 \(m\). 考虑设 \(f_{i,j}\) 表示所有 \(3^m\) 个字符串的前 \(i\) 个字符中,子序列 a,…
题目链接 题目大意 给你一个长为d只包含字符'a','b','c','?' 的字符串,?可以变成a,b,c字符,假如有x个?字符,那么有\(3^x\)个字符串,求所有字符串种子序列包含多少个abc子序列 题目思路 假如没有问号,那么就是一个简单的dp \(dp[i][1]为前i个位置有多少个a\) \(dp[i][2]为前i个位置有多少个ab\) \(dp[i][3]为前i个位置有多少个abc\) 考虑 '?' 会对 dp 的转移产生什么影响,因为 '?' 可以将三种字母全部都表示一遍,所以到了…
http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits:  5000 MS   Memory Limits:  200000 KB 64-bit interger IO format:  %lld   Java class name:  Main Description A Hill Number is a number whose digits possibly rise and then possibl…
Friends and Subsequences 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/H Description Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on the…
Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to 1. Given an array a consisting of n positive integers, find the number of its coprime subsequences.…
[题目链接]:http://codeforces.com/contest/803/problem/F [题意] 给你一个序列; 问你这个序列里面有多少个子列; 且这个子列里面的所有数字互质; [题解] 计算cnt[x]; 表示数组里有多少个数是x的倍数; 则某个子列里面所有的数字都能被x整除的子列个数为2cnt[x]−1 把这个值记为f[x]; 则我们用需要用容斥原理; 把所有能被2,3,..n整除的子列删除掉; 这里面会有重复计数的问题; 解决方式是,从大到小枚举f[x] 然后对于y=i*x的…
E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Given the number n, find the smallest positive integer which has exactly n divisors. It is guara…
题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #includ…
http://codeforces.com/contest/235/problem/E 远距离orz......rng_58 证明可以见这里(可能要FQ才能看到) 还是copy一下证明吧: 记 $$f(a,b,c)=\sum\limits_{i=1}^{a}\sum\limits_{j=1}^{b}\sum\limits_{k=1}^{c}d(ijk)$$ 和 $$g(a,b,c)=\sum\limits_{gcd(i,j)=gcd(j,k)=gcd(i,k)=1}\left \lfloor \…
题目链接:http://codeforces.com/problemset/problem/1151/E 题目大意: n个人排成一个序列,标号为 1~n,第 i 个人的学习成绩为 ai,现在要选出学习成绩在区间 [l, r] 中的人,被选出的人如果他们在序列中相邻,就将他们划分到一个小组,设 f(l, r) 表示一共可以分出的组的个数.求这个和:$ \sum_{l = 1}^n \sum_{r = 1}^n f(l, r) $. 分析: 对于每一个学生,都有作为它所在小组区间左端点和右端点的时候…