First, take 1000 as an example.
Set the mean of the number to X and the number to n.
1. When n is an odd number, X is an integer. (X is equal to the median of N numbers) at this time, n is an odd number of 1000 factors, total N = 1, n = 5, n = 25, n = 125 four, the corresponding x values are x = 1000,200, and 8, respectively. 2. if n is an even number and X is a decimal point of 0.5,2x is an odd number.If 2x = Y, there are N * Y = 2000. At this time, the odd number in the factor of Y is 2000, which includes y = 25,125 and 2000,400, then the corresponding N is, 80, 16. X = 0.5, 2.5, 12.5, 62.5 so a total of 8 Consecutive Integers equals 2000. N = 1, 1000; n = 5, 198,199,200,201,202 n = 25 ,..., 40 ,..., 51, 52n = 125,-54,-53 ,..., 8 ,..., 69, 70N = 16, 55,56 ,..., 62,63 ,..., 69, 70N = 80,-27,-26 ,..., 12, 13 ,... 51, 52n = 400,-197,-196 ,..., 2, 3 ,..., 201,202 n = 2000,-999,-998 ,..., 0, 1 ,... 999,1000
The preceding analysis method contains negative groups.
What should we do if we only consider a continuous positive integer?
The maximum number of consecutive integers in a positive integer m is: n (n + 1)/2 = m starting from 1; where N is the length of the longest continuous integer for m.N <= SQRT (2 * m)
Therefore, to make all integers a positive integer, make sure that the number of positive integers in each group does not exceed n.
In the first case, find the number of n <= n C1;
In the second case, find the number of 2n/Y <= n C2;
Final ResultC1 + C2;
I will post my most recent question and personal problem solving here.
★Lab task
Most positive integers can be expressed as more than twoContinuous integer. For example
6 = 1 + 2 + 3
9 = 5 + 4 = 2 + 3 + 4
It is required to calculate the number of two or more integers that can be expressed as a given positive integer.The sum of Consecutive Integers(The number of partition schemes ).
★Data Input
There is only one row of input data, a positive integer N (1 <=n <= 1000 ).
★Data Output
Output the number of consecutive integer decomposition solutions.
1 # include <stdio. h> 2 # include <string. h> 3 # include <math. h> 4 int main () 5 {6 int I = 1, n, Count = 0; 7 scanf ("% d", & N); 8 int max = (INT) (SQRT (2 * n); 9 While (I <n) {// The number of groups is an odd number of 10 if (I % 2 = 1 & N % I = 0 & N/I <= max) {11 count ++ ;} 12 I ++; 13} 14 I = 0; 15 while (I <2 * n) {16 if (I % 2 = 1 & 2 * n % I = 0 & 2 * n/I <= max) {17 count ++ ;} 18 I ++; 19} 20 printf ("% d \ n", count); 21 return 0; 22}
Reprinted please mark http://home.cnblogs.com/u/plxx/
The sum of continuous integers in an algorithm