枚举区间可能的长度len,将m减去1~len构成的序列和后如果结果是len的倍数,则可以构成答案区间. /* Written By. StelaYuri */ #include<stdio.h> #include<math.h> int main(){ int n,m,len,b; while(scanf("%d%d",&n,&m)!=EOF&&(n||m)){ );len;len--){ b=m-(len*len+len)/;…
https://en.wikipedia.org/wiki/Subset_sum_problem In computer science, the subset sum problem is an important problem in complexity theory and cryptography. The problem is this: given a set (or multiset) of integers, is there a non-empty subset whose…
Sum Problem Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 338086 Accepted Submission(s): 85117 Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this pro…
The sum problem Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12422 Accepted Submission(s): 3757 Problem Description Given a sequence 1,2,3,......N, your job is to calculate all the possible sub…
We have a lot of ways to solve the maximum subsequence sum problem, but different ways take different time. 1.Brute-force algorithm int maxSubSum1(const vector<int> &a) { int maxSum=0; for(int i=0;i<a.size();i++) for(int j=i;j<a.size();j++…
The sum problem Problem Description Given a sequence 1,2,3,......N, your job is to calculate all the possible sub-sequences that the sum of the sub-sequence is M. Input Input contains multiple test cases. each case contains two integers N, M( 1 <=…
The sum problem Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 31453 Accepted Submission(s): 9414 Problem Description Given a sequence 1,2,3,......N, your job is to calculate all the possib…