题意:https://codeforc.es/contest/1207/problem/D n个元素,每个元素有a.b两个属性,问你n个元素的a序列和b序列有多少种排序方法使他们不同时非递减(不同时good). 思路: 真难则反+容斥,反向考虑,ans1=如果a序列非递减则有a中各个数字出现次数的阶乘的乘积个,ans2=b序列也是一样. ans3=然后还要减去a序列和b序列都是good的方案数,就是元素相同的出现次数阶乘的乘积(注意,如果不存在双good就不算ans3). ANS就是:全排列 -…
题目链接:http://codeforces.com/contest/1036/problem/F 题意: 题解:求在[2,n]中,x != a ^ b(b >= 2 即为gcd)的个数,那么实际上就是要求x = a ^ b的个数,然后用总数减掉就好了,答案即为.(pow会丢失精度,学习避免精度丢失的方法) #include <bits/stdc++.h> using namespace std; #define ll long long #define LL __int128 #def…
链接:https://codeforces.com/contest/1167/problem/A 题意: A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388and 80000011223388 are n…
题目链接:https://codeforces.com/contest/1437/problem/E 题意 给出一个大小为 \(n\) 的数组 \(a\) 和一个下标数组 \(b\),每次操作可以选择数组 \(b\) 外的任意下标 \(i\) 并将 \(a_i\) 赋值为任意数,问能否经过操作使得数组 \(a\) 严格递增,如果可以,计算所需的最少操作次数. 题解 令 \(c_i = a_i - i\),如果数组 \(a\) 严格递增,那么数组 \(c\) 一定为非递减序. 所以判断下标数组 \…
题: OvO http://codeforces.com/contest/946/problem/E CF 946E 解: 记读入串为 s ,答案串为 ans,记读入串长度为 len,下标从 1 开始. 分三种情况讨论 1.数字位数为奇数,设数字位数为 len,则输出 ( len-1 ) 个 9 即可 ,最低位为 或者,其他位为 ,(即 100001,100 这些形式),记数字位数为 len,则输出 ( len-2 ) 个 9 即可 3.数字位数为偶数,而并非是第二种情况,那么进行一次 dfs…
G. List Of Integers time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Let's denote as L(x, p) an infinite sequence of integers y such that gcd(p, y) = 1 and y > x (where gcd is the greatest…
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a. Let number i be in positions xi, yi (xi < yi) i…
D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You are given n points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertice…
本题地址: https://codeforces.com/contest/1215/problem/B 本场比赛A题题解:https://www.cnblogs.com/liyexin/p/11535519.html B. The Number of Products time limit per test 2 seconds memory limit per test 256 megabytes input standard input output   standard output You…
2015 asia xian regional F Color (容斥 + 组合数学) 题目链接http://codeforces.com/gym/100548/attachments Description Recently, Mr. Bigrecieved n flowers from his fans. He wants to recolor those flowerswith m colors. The flowers are put in a line. It is not allow…
Yada Number Problem Description: Every positive integer can be expressed by multiplication of prime integers. Duoxida says an integer is a yada number if the total amount of 2,3,5,7,11,13 in its prime factors is even. For instance, 18=2 * 3 * 3 is no…
至今觉得这场 edu 的 G 比 EF 都要简单-- 不知道为什么出题人要把 \(m=0\) 放进去,先特判掉. 要求至少一个 \(0\),至少一个 \(1\),至少一个 \(2\),容斥一波,变成总方案数-没有 \(0\)-没有 \(1\)-没有 \(2\)+没有 \(01\)+没有 \(02\)+没有 \(12\)+没有 \(012\). 没有 \(0\) 和没有 \(2\) 比较难搞,放到最后讨论. 没有 \(1\),考虑一个联通块,这个联通块所有数都一样,方案数是 \(2^{cnt}\)…
GCD Expectation Time Limit: 4 Seconds     Memory Limit: 262144 KB Edward has a set of n integers {a1,a2,...,an}. He randomly picks a nonempty subset {x1,x2,-,xm} (each nonempty subset has equal probability to be picked), and would like to know the ex…
A Simple Chess 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5794 Description There is a n×m board, a chess want to go to the position (n,m) from the position (1,1). The chess is able to go to position (x2,y2) from the position (x1,y1), only and if…
Co-prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5526    Accepted Submission(s): 2209 Problem Description Given a number N, you are asked to count the number of integers between A and B…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3556 How Many Sets I Time Limit: 2 Seconds      Memory Limit: 65536 KB Give a set S, |S| = n, then how many ordered set group (S1, S2, ..., Sk) satisfies S1 ∩ S2 ∩ ... ∩ Sk = ∅. (Si is…
这道题,先说一下单色三角形吧,推荐一篇noip的论文<国家集训队2003论文集许智磊> 链接:https://wenku.baidu.com/view/e87725c52cc58bd63186bd1b.html?from=search 单色三角形指的是n个顶点,有n(n-1)条边,很明显是每个点两两相连,那么这样所形成的所有三角形的边假如有两种颜色:红和黑.那么问一共有多少三角形的三边是一种颜色的个数. ,建议看一下那个论文,因为我只能直接给出你结论.  下面的数学符号:{...}为概率论中表…
$\min - \max$ 容斥 Part 1 对于简单的$\min - \max$容斥有一般形式,表达为:$\max(S)=\sum\limits_{T\subseteq S}(-1)^{|T|-1}\times \min(T)$ 对于上述式子,可以简单的理解. 对于$S$中的每一项,其中的最大值为第$i$项 由于$|T|$非空,一共有$2^{|S|}-1$个$T$,其中,对于非最大值的任意一项,都包含至少一个比其大的元素 所以这些元素的选择情况构成了$2^{k}$幂,其中$|T|$的奇偶分布…
大意: 给定集合a, 求a的按位与和等于0的非空子集数. 首先由容斥可以得到 $ans = \sum \limits_{0\le x <2^{20}} (-1)^{\alpha} f_x$, 其中$\alpha$为$x$二进制中$1$的个数, $f_x$表示与和等于$x$的非空子集数. $f_x$是一个$20$维前缀和, 按传统容斥做法的话显然要超时, 可以每次求一维的和, 再累加 比方说对于2维前缀和, 用容斥的求法是这样 for (int i=1; i<=n; ++i) { for (in…
Co-prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 935    Accepted Submission(s): 339 Problem Description Given a number N, you are asked to count the number of integers between A and B in…
题目链接 Problem Description You are given an array A , and Zhu wants to know there are how many different array B satisfy the following conditions? 1≤Bi≤Ai For each pair( l , r ) (1≤l≤r≤n) , gcd(bl,bl+1...br)≥2 Input The first line is an integer T(1≤T≤1…
Card Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5254    Accepted Submission(s): 2676Special Judge Problem Description In your childhood, do you crazy for collecting the beautiful…
很好很有趣很神仙的题! 题目链接: https://loj.ac/problem/2542 题意: 请自行阅读 题解首先我们显然要求的是几个随机变量的最大值的期望(不是期望的最大值),然后这玩意很难求,根据Min-Max容斥化成最小值的期望来求. Minn-max容斥是指\(\max(x_1,x_2,...,x_n)=\sum_{S\in \{1,2,...,n\} } (-1)^{|S|-1} \min_{i\in S}(x_i)\) (所有元素都是正整数,这个尽管式子本身和期望没关系但是经常…
How many integers can you find Time Limit: 12000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6048    Accepted Submission(s): 1735 Problem Description   Now you get a number N, and a M-integers set, you shou…
How many integers can you find Time Limit: 12000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6710    Accepted Submission(s): 1946 Problem Description   Now you get a number N, and a M-integers set, you shou…
ARC115 E AtCoder Problem Statement Given is a sequence of \(N\) integers \(A_1\),\(A_2\),...,\(A_N\). Print the number, modulo \(998244353\), of sequence of \(N\) integers \(X_1\),\(X_2\),...,\(X_N\) satisfying all of the following conditions: \(1 \l…
集合计数 内存限制:128 MiB 时间限制:1000 ms 标准输入输出     题目描述 一个有N个元素的集合有2^N个不同子集(包含空集),现在要在这2^N个集合中取出若干集合(至少一个),使得它们的交集的元素个数为K,求取法的方案数,答案模1000000007.(是质数喔~) 输入格式 一行两个整数N,K 输出格式 一行为答案. 样例 样例输入 3 2 样例输出 6 数据范围与提示 样例说明 假设原集合为{A,B,C} 则满足条件的方案为:{AB,ABC},{AC,ABC},{BC,AB…
C. Mike and Foam time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are n kinds of beer at Rico's…
题目 Source http://acm.hust.edu.cn/vjudge/problem/42145 Description Let’s assume there is a new chess piece named Super-rook. When placed at a cell of a chessboard, it attacks all the cells that belong to the same row or same column. Additionally it at…
How many integers can you find Time Limit: 12000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4249    Accepted Submission(s): 1211 Problem Description   Now you get a number N, and a M-integers set, you shoul…