题目:http://acm.hdu.edu.cn/showproblem.php?pid=4651 参考:https://blog.csdn.net/u013007900/article/details/42365823 https://blog.csdn.net/visit_world/article/details/52734860 好像这样复杂度就是 \( O(n\sqrt{n} \) 的了. #include<cstdio> #include<cstring> #inclu…
Integer Partition Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22    Accepted Submission(s): 15 Problem Description Given n, k, calculate the number of different (unordered) partitions of n s…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4658 题意:给出n.k.求n的拆分方案数.要求拆分中每个数不超过k. i64 f[N]; void init(){    f[0]=f[1]=1; f[2]=2;    int i,j,k,t;    for(i=3;i<N;i++) for(j=1;;j++)    {        FOR0(k,2)        {            if(!k) t=(3*j*j-j)/2;     …
五角数定理!!可以参考这个http://www.cnblogs.com/xin-hua/p/3242428.html  代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<string> #include<vector> #define ll __int64 #de…
Partition Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 462    Accepted Submission(s): 262 Problem Description How many ways can the numbers 1 to 15 be added together to make 15? The technica…
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. For example, given n = 2, return 1 (2 = 1 + 1); given n = 10, return 36 (10 = 3 +…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4651 题意:求n的整数拆为Σ i 的个数. 一般的递归做法,或者生成函数做法肯定会超时的... 然后要奇葩的用到一个<五边形数定理>,然后根据公式递推就可以了,先预处理下,复杂度O(n*sqrt(n)).. //STATUS:C++_AC_796MS_1012KB #include <functional> #include <algorithm> #include <…
给定一个正整数 n,将其拆分为至少两个正整数的和,并使这些整数的乘积最大化. 返回你可以获得的最大乘积.例如,给定 n = 2,返回1(2 = 1 + 1):给定 n = 10,返回36(10 = 3 + 3 + 4).注意:你可以假设 n 不小于2且不大于58. 详见:https://leetcode.com/problems/integer-break/description/ C++: class Solution { public: int integerBreak(int n) { i…
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. Example 1: Input: 2 Output: 1 Explanation: 2 = 1 + 1, 1 × 1 = 1. Example 2: Input:…
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9728    Accepted Submission(s): 6668 Problem Description People in Silverland use square coins. Not…