HDU2058 The sum problem 題解
阿新 • • 發佈:2019-02-19
空行 miss chmod NPU scrip inpu sample 輸出 -i
The sum problem
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 33407 Accepted Submission(s): 9948
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.
給出一個序列1,2,3.....N,你的任務是計算出所有可能的和為M的子序列
Input
Input contains multiple test cases. each case contains two integers N, M( 1 <= N, M <= 1000000000).input ends with N = M = 0.
輸入包括多行,每個用例包括兩個整數N,M(很大),當N=M=0時輸入結束
Output
For each test case, print all the possible sub-sequence that its sum is M.The format is show in the sample below.print a blank line after each test case.
對於每個測試用例,輸出所有的和為M的子序列,格式如同下方的樣例。每個測試用例之間用一個空行隔開
Sample Input
20 10
50 30
0 0
Sample Output
[1,4]
[10,10]
[4,8]
[6,9]
[9,11]
[30,30]
Author
8600
Source
校慶杯Warm Up
Analysis
看上去似乎是子序列問題,其實就是一個等差數列,這裏的N和M非常大,因此如果暴力一定TLE。
HDU2058 The sum problem 題解