ConstitutiveNumbers
TCCC06 Sponsor 2 · 2006-08-22 · by Andrew_Lazarev
Problem Statement
Let's call a number constitutive if it can be expressed as a sum of three or more successive positive integers. For example, 14 is a constitutive number because 14 = 2+3+4+5, but 13 is not a constitutive number.
You will be given two
Constraints
- A will be between 1 and 1,000,000,000, inclusive.
- B will be between A and A + 1000, inclusive.
1 15 Returns: 6
The first 6 constitutive numbers are: 6 = 1 + 2 + 3 9 = 2 + 3 + 4 10 = 1 + 2 + 3 + 4 12 = 3 + 4 + 5 14 = 2 + 3 + 4 + 5 15 = 4 + 5 + 6
1 101 Returns: 69
1000 1030 Returns: 26
7245723 7246428 Returns: 657
1000000000 1000001000 Returns: 952
Submissions are judged against all 105 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ConstitutiveNumbers with a public method int count(int A, int B) · 105 test cases · 2 s / 256 MB per case