Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SOLUTION HINTS For Light OJ 1278 - Sum of Consecutive Integers:
- THE MEANING OF THE QUESTIONS: Given n, n can be written in
- the form of at least two consecutive positive integers and the
- number of species.
- IDEAS: Let n can be written as a, a +1, a +2 ...... a + k-1's and (a> = 1),
- i.e., n = (a + a + k-1) * k / 2.
- If k is odd, then, N = (A + (k-1) / 2) * k.
- If k is even, then (a + a + k-1) is an odd number.
- So if there are a set of solutions, must correspond to an odd prime.
- THE FOLLOWING PROVED, a odd prime number other than 1, each odd prime number corresponds to a solution.
- Let x n is an odd prime number, so that y = n / x. Then the relationship between x and y, only the following two:
- (1) y> (x-1) / 2, In this case, n must be able to be written as n = (a + (k-1) / 2) * k of the form.
- Wherein x = K, y = a - a + (k-1) / 2, this time to meet a = y-(K-1) / 2 = y-(x-1) / 2 is a positive integer;
- (2) y <= (x-1) / 2, where n must be able to be written as n = n = (a + a + k-1) * k / 2 of the form.
- Wherein, y = k / 2, x = a + A + k-1.
- This time A = (x +1- k) / 2 = (x +1- y * 2) / 2 = (x-1) / 2-y +1> = 1.
- THEREFORE, an odd prime number must correspond to a solution.
Advertisement
Add Comment
Please, Sign In to add comment