题意:给你一组数,选一些数出来组成一个排列,使得每个数都能被前一个数整除,求排列的最大元素. 题解:我们先用欧拉筛筛出\(1e7\)的质数,设\(dp[i]\)表示当前选的数都是\(i\)的约数且合法的最大元素值.所以我们可以用\(dp[i]\)去更新\(i\)的倍数的\(dp\)值,我们可以靠枚举\(i\)的素数倍来降低复杂度,因为合数总是可以由若干的素数的乘积得来. 代码: int n; int x; int mp[N]; int primes[N],cnt; bool st[N]; int…
Distinct Values Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4869 Accepted Submission(s): 1659 Problem Description Chiaki has an array of n positive integers. You are told some facts about…
前缀和以及二维前缀和在这里就不写了. 差分:是前缀和的逆运算 ACWING二维差分矩阵 每一个二维数组上的元素都可以用(x,y)表示,对于某一元素(x0,y0),其前缀和就是以该点作为右下角以整个数组的起始点作为左上角的矩形区域内所有元素的和.[如下图的红色区域,其中六个元素的和就是(x0,y0)的前缀和] #include<cstring> #include<iostream> using namespace std; ; int n,m,q; int a[maxn][ma…
Contest1585 - 2018-2019赛季多校联合新生训练赛第一场 C 10187 查找特定的合数 D 10188 传话游戏 H 10192 扫雷游戏 C 传送门 题干: 题目描述 自然数中除了能被1和本身整除外,还能被其他数整除的数叫合数.每个合数都可以写成几个质数相乘的形式,这几个质数都叫做这个合数的质因数.比如8=××,2就是8的质因数.在1—N(N≤)按从小到大顺序排列的自然数序列中,查找第M个有X(≤X≤)个不同质因数的合数.例如,第3个有2个不同质因数的合数是12(12只有2…
Tree and Permutation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 619 Accepted Submission(s): 214 Problem Description There are N vertices connected by N−1 edges, each edge has its own len…
Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migic tree, the tree has N nodes , in each node , there is a treasure, it's value is V[i], and for each edge, there is a cost C[i], which means every time…
Robots Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 60 Accepted Submission(s): 13 Problem Description QXJ has N robots on the plane, the i-th is at (xi,yi), numbereded 1 to N. Every robot…
比赛时间只有两个小时,我没有选做这题,因为当时看样例也看不懂,比较烦恼. 后来发现,该题对输入输出要求很低.远远没有昨天我在做的A题的麻烦,赛后认真看了一下就明白了,写了一下,一次就AC了,没问题,真心有点后悔. 来先看题目: C. Practice time limit per test 1 second memory limit per test 256 megabytes input input.txt output output.txt Little time is left befor…
pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6447 Problem DescriptionYJJ is a salesman who has traveled through western country. YJJ is always on journey. Either is he at the destination, or on the way to destination.One day, he is going to travel…