Editorial
Let's construct the required sequence in a constructive manner. Since the sine function is periodic with a period of , we will look for it in the form of , where . We need to find such a positive integer for which there exists an integer such that , where is as small as possible. For example, if we check values of from to , the smallest is achieved when . In this case, .
Let . Consider the sequence
The values of the elements in this sequence are
or, considering the periodicity, these values are equivalent to
The function is increasing on the interval . For the sequence of the above real numbers to be monotonically increasing, it is sufficient to satisfy the inequality: . Substituting and , we get: or , which is true. Therefore, by this method, it is possible to find required integers.
Algorithm realization
Read the input value of .
scanf("%d", &n);
On the interval , we find such a positive integer for which, when represented as , the value of will be the smallest.
bestA = 0; bestE = 2 * PI; for (a = 1; a < 1000; a++) { e = fmod(a, 2.0 * PI); if (e < bestE) { bestE = e; bestA = a; } }
The value of will be .
x = bestA;
Print the desired sequence: .
for (i = 0; i < n; i++) printf("%d ", x * i); printf("\n");