HDU 5646 DZY Loves Partition】的更多相关文章

DZY Loves Partition 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5646 Description DZY loves partitioning numbers. He wants to know whether it is possible to partition n into the sum of exactly k distinct positive integers. After some thinking he f…
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5646 bc:http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=680&pid=1002 DZY Loves Connecting Accepts: 16     Submissions: 169 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 26…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5646 题意:将n分成k个正整数之和,要求k个数全部相同:并且这k个数的乘积最大为多少?结果mod 1e^9+7; 思路:由于是mod,不能通过模拟进行比较来判断是否为最优解:那么我们就必须直接计算出这个最优解的序列: 由于当a <= b-2时(相等时表示中间空一位),a*b < (a+1)*(b-1);所以最优解序列要不就是一串连续的序列,要不就是中间空一位,分成两段连续的序列: 因为如果存在空格超过…
题目链接: DZY Loves Partition Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 323    Accepted Submission(s): 127 Problem Description DZY loves partitioning numbers. He wants to know whether it is…
DZY Loves Balls 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5645 Description DZY loves playing balls. He has n balls in a big box. On each ball there is an integer written. One day he decides to pick two balls from the box. First he randomly pick…
DZY Loves Topological Sorting Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5195 Description A topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for ev…
传送门 DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 221    Accepted Submission(s): 52 Problem Description A topological sort or topological ordering of a directed…
DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 866    Accepted Submission(s): 250 Problem Description A topological sort or topological ordering of a directed g…
DZY Loves Sorting Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 294    Accepted Submission(s): 77 Problem Description DZY has a sequence a[1..n]. It is a permutation of integers 1∼n. Now he…
DZY Loves Balls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 807    Accepted Submission(s): 439 Problem Description There are n black balls and m white balls in the big box. Now, DZY starts…
DZY Loves Balls  Accepts: 659  Submissions: 1393  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: 262144/262144 K (Java/Others) 问题描述 DZY喜欢玩球. 他有nn个球,装进一个大盒子里.每个球上面都写着一个整数. 有一天他打算从盒子中挑两个球出来.他先均匀随机地从盒子中挑出一个球,记为AA.他不把AA放回盒子,然后再从盒子中均匀随机地挑出一个球,记为BB.…
DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1250    Accepted Submission(s): 403 Problem Description A topological sort or topological ordering of a directed g…
DZY Loves Sorting Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 753    Accepted Submission(s): 249 Problem Description DZY has a sequence a[1..n]. It is a permutation of integers 1∼n. Now h…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5647 题解: 令dp[u][0]表示u所在的子树中所有的包含i的集合数,设u的儿子为vi,则易知dp[u][0]=(dp[v1][0]+1)*...*(dp[vk][0]+1). 令dp[u][1]表示u所在的子树中所有的包含i的集合数的大小的和,则有dp[u][1]=dp[u][1]*(dp[v][0]+1)+dp[v][1]*dp[u][0]: 其中dp[u][1]*(dp[v][0]+1)表…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5648 题意:给定n,m(1<= n,m <= 15,000),求Σgcd(i|j,i&j);(1 <= i <= n,1<=j<=m); 至多三组数据,至多两组数据max(n,m) > 2000.至多一组数据max(n,m) > 8000; 很多题解是用递推打表,将数据压缩250倍,即[i][j]:代表[1...250*i][1...250*j],之后零…
问题描述 DZY喜欢拆分数字.他想知道能否把nn拆成恰好kk个不重复的正整数之和. 思考了一会儿之后他发现这个题太简单,于是他想要最大化这kk个正整数的乘积.你能帮帮他吗? 由于答案可能很大,请模109710​9​​+7输出. 输入描述 第一行tt,表示有tt组数据. 接下来tt组数据.每组数据包含一行两个正整数nkn,k. (1t502nk1091≤t≤50,2≤n,k≤10​9​​) 输出描述 对于每个数据,如果不存在拆分方案,输出1−1:否则输出最大乘积模109710​9​​+7之后的值.…
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5195 bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=573&pid=1002 题解: 1.拓扑排序+贪心 #include<algorithm> #include<iostream> #include<cstring> #include<cstdi…
题意:BC 76 div1 1003有中文题面 然后官方题解看不懂,我就不说了,然后看别人的题解 因为询问i,j最大都是15000,所以可以预处理,res[i][j]代表答案,然后显然这是开不下的,也交不了这么大的表 那我们退而求其次,只求一部分区间,由于最大15000,这样15000/60=250,我们只打 i 和 j是250的整数倍的答案 这样开ans[61][61]的数组就可以了,然后ans[1][1]就是res[250][250],以此类推 这样打表以后,每次答案,进入以后n,m,找到最…
题意: 删去K条边,使拓扑排序后序列字典序最大 分析: 因为我们要求最后的拓扑序列字典序最大,所以一定要贪心地将标号越大的点越早入队.我们定义点i的入度为di. 假设当前还能删去k条边,那么我们一定会把当前还没入队的di≤k的最大的i找出来,把它的di条入边都删掉,然后加入拓扑序列. 删除的一定是小连大的边,因为大连小的边在拓扑序列生成的时候就去掉了 #include <iostream> #include <cstdio> #include <queue> #incl…
题目链接 给一个序列, 两种操作, 一种是将[l, r]里所有数升序排列, 一种是降序排列. 所有操作完了之后, 问你a[k]等于多少. 真心是涨见识了这题..好厉害. 因为最后只询问一个位置, 所以我们二分这个位置的值. 将所有大于等于它的值赋为1, 小于的赋为0. 然后现在整个序列只有01, 更改什么的线段树就很好搞. 如果a[k]最后为1, 那么我们增加l, 否则减少r. 那么为什么可以这样呢. 因为二分mid的时候, 将等于mid的也赋为了1, 所以如果a[k]是0的话,代表mid比答案…
题意 一个 \(1\) 到 \(n\) 的全排列,\(m\) 种操作,每次将一段区间 \([l,r]\) 按升序或降序排列,求 \(m\) 次操作后的第 \(k\) 位. \(1 \leq n \leq 10^5\) 思路 两个 \(\log\) 的做法展现了二分答案的强大功能.首先二分枚举第 \(k\) 位的值,然后将小于等于它的数都变为 \(1\) ,大于它的数变为 \(0\) ,线段树可以实现对 \(01\) 序列快速的排序,按要求进行排序,然后如果第 \(k\) 位为 \(1\) 说明这…
DZY Loves Partition  Accepts: 154  Submissions: 843  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: 262144/262144 K (Java/Others) 问题描述 DZY喜欢拆分数字.他想知道能否把nn拆成恰好kk个不重复的正整数之和. 思考了一会儿之后他发现这个题太简单,于是他想要最大化这kk个正整数的乘积.你能帮帮他吗? 由于答案可能很大,请模10^9+710​9​​+7输…
DZY Loves Partition Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 815    Accepted Submission(s): 298 Problem Description DZY loves partitioning numbers. He wants to know whether it is possib…
pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 332    Accepted Submission(s): 112 Problem Description DZY has an unroote…
hdu5197 DZY Loves Orzing(FFT+分治) hdu 题目描述:一个n*n的矩阵里填入1~n^2的数,要求每一排从前往后能看到a[i]个数(类似于身高阻挡视线那种),求方案数. 思路: 考虑往一排里填入n个数. 经过简单推导发现正好有j个能被看到的方案数答案是$\Sigma_{i=1}^{n}(x+(i-1))$的$x^{j}$项系数. 这个用分治FFT搞一搞就会变成$nlog^{2}n$的了. 之后再乘上一个$\frac{(n^{2})!}{(n!)^{n}}$ woc这什…
C. DZY Loves Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they…
题目 Source http://codeforces.com/problemset/problem/444/C Description DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they are numbered from 1 to n from left to right). The color of t…
A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. Some cells of the c…
3309: DZY Loves Math Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 761  Solved: 401[Submit][Status][Discuss] Description 对于正整数n,定义f(n)为n所含质因子的最大幂指数.例如f(1960)=f(2^3 * 5^1 * 7^2)=3, f(10007)=1, f(1)=0.给定正整数a,b,求sigma(sigma(f(gcd(i,j)))) (i=1..a, j=1.…
题目链接: 传送门 DZY Loves Chemistry time limit per test1 second     memory limit per test256 megabytes Description DZY loves Physics, and he enjoys calculating density. Almost everything has density, even a graph. We define the density of a non-directed gr…