Programming Taskbook


E-mail:

Password:

User registration   Restore password

Russian

SFedU

1100 training tasks on programming

©  M. E. Abramyan (Southern Federal University), 1998–2018

 

Tasks | Task groups | Series

PrevNext


Numerical sequences

All input numerical sequences in tasks of this group contains one or more elements (in particular, an integer N is always greater than 0). In tasks Series29–Series40 the amount K of input sequences is assumed to be nonzero too.

Series1. Given ten real numbers, find their sum.

Series2. Given ten real numbers, find their product.

Series3. Given ten real numbers, find their average.

Series4. An integer N and a sequence of N real numbers are given. Output the sum and the product of all elements of this sequence.

Series5. An integer N and a sequence of N positive real numbers are given. Output in the same order the integer parts of all elements of this sequence (as real numbers with zero fractional part). Also output the sum of all integer parts.

Series6. An integer N and a sequence of N positive real numbers are given. Output in the same order the fractional parts of all elements of this sequence (as real numbers with zero integer part). Also output the product of all fractional parts.

Series7. An integer N and a sequence of N real numbers are given. Output in the same order the rounded values of all elements of this sequence to the nearest whole number (as integers). Also output the sum of all rounded values.

Series8. An integer N and a sequence of N integers are given. Output in the same order all even-valued elements of the sequence and also their amount K.

Series9. An integer N and a sequence of N integers are given. Output in the same order the order numbers of all odd-valued elements of the sequence and also their amount K.

Series10. An integer N and a sequence of N integers are given. Output the logical value True if the sequence contains positive-valued elements, otherwise output False.

Series11. Integers KN and a sequence of N integers are given. Output the logical value False if the sequence contains elements of value less than K, otherwise output False.

Series12. A sequence of nonzero integers terminated by zero is given (the final zero is not an element of the sequence). Output the length of the sequence.

Series13. A sequence of nonzero integers terminated by zero is given. Output the sum of all positive-valued elements of the sequence. If the sequence does not contain the required elements then output 0.

Series14. An integer K and a sequence of nonzero integers terminated by zero are given (the final zero is not an element of the sequence). Output the amount of elements whose value less than K.

Series15. An integer K and a sequence of nonzero integers terminated by zero are given (the final zero is not an element of the sequence). Output the order number of the first element whose value greater than K. If the sequence does not contain the required elements then output 0.

Series16. An integer K and a sequence of nonzero integers terminated by zero are given (the final zero is not an element of the sequence). Output the order number of the last element whose value greater than K. If the sequence does not contain the required elements then output 0.

Series17. A real number B, an integer N and a sequence of N real numbers are given. The values of elements of the sequence are in ascending order. Output the number B jointly with the elements of the sequence so that all output numbers were in ascending order.

Series18. An integer N and a sequence of N integers are given. The values of elements of the sequence are in ascending order, the sequence may contain equal elements. Output in the same order all distinct elements of the sequence.

Series19. An integer N (> 1) and a sequence of N integers are given. Output the elements that are less than their left-side neighbor. Also output the amount K of such elements.

Series20. An integer N (> 1) and a sequence of N integers are given. Output the elements that are less than their right-side neighbor. Also output the amount K of such elements.

Series21. An integer N (> 1) and a sequence of N real numbers are given. Output the logical value True if the values of elements are in ascending order, otherwise output False.

Series22. An integer N (> 1) and a sequence of N real numbers are given. Output 0 if the values of elements are in descending order, otherwise output the order number of the first element that breaks the required order.

Series23. An integer N (> 2) and a sequence of N real numbers are given. A sequence is called a sawtooth one if each inner element of the sequence is either greater or less than both of its neighbors (that is, each inner element is a tooth). Output 0 if the given sequence is a sawtooth one, otherwise output the order number of the first element that is not a tooth.

Series24. An integer N and a sequence of N integers are given. The sequence contains at least two zero-valued elements. Output the sum of the values of elements placed between two last zero-valued elements. If two last zero-valued elements are placed side by side then output 0.

Series25. An integer N and a sequence of N integers are given. The sequence contains at least two zero-valued elements. Output the sum of the values of elements placed between the first and the last zero-valued elements. If the first and the last zero-valued elements are placed side by side then output 0.

Numerical sequences: nested loops

Series26. Positive integers K, N and a sequence of N real numbers A1, A2, …, AN are given. For each element of the sequence find its value raised to the power of K:

(A1)K, (A2)K, …, (AN)K.

Series27. An integer N and a sequence of N real numbers A1, A2, …, AN are given. Output the following numbers:

A1, (A2)2, …, (AN−1)N−1, (AN)N.

Series28. An integer N and a sequence of N real numbers A1, A2, …, AN are given. Output the following numbers:

(A1)N, (A2)N−1, …, (AN−1)2, AN.

Series29. Integers K, N and K sequences of integers are given. Each given sequence contains N elements. Find the total sum of the values of elements of all given sequences.

Series30. Integers K, N and K sequences of integers are given. Each given sequence contains N elements. Find the sum of the values of all elements for each given sequence.

Series31. Integers K, N and K sequences of integers are given. Each given sequence contains N elements. Find the amount of the sequences containing an element with the value 2.

Series32. Integers K, N and K sequences of integers are given. Each given sequence contains N elements. Output the order number of the first element with the value 2 for each given sequence (if a sequence does not contain elements with the required value then output 0).

Series33. Integers K, N and K sequences of integers are given. Each given sequence contains N elements. Output the order number of the last element with the value 2 for each given sequence (if a sequence does not contain elements with the required value then output 0).

Series34. Integers K, N and K sequences of integers are given. Each given sequence contains N elements. Process each sequence as follows: output the sum of the values of all its elements if the sequence contains an element with the value 2, otherwise output 0.

Series35. An integer K and K sequences of nonzero integers are given. Each given sequence is terminated by zero, which is not an element of the sequence. Output the length of each given sequence. Also output the total length of all given sequences.

Series36. An integer K and K sequences of nonzero integers are given. Each given sequence contains at least two elements and is terminated by zero, which is not an element of the sequence. Output the amount of the sequences whose element values are in ascending order.

Series37. An integer K and K sequences of nonzero integers are given. Each given sequence contains at least two elements and is terminated by zero, which is not an element of the sequence. Output the amount of sequences whose element values are in ascending or in descending order.

Series38. An integer K and K sequences of nonzero integers are given. Each given sequence contains at least two elements and is terminated by zero, which is not an element of the sequence. Process each sequence as follows: output 1 or −1 if its element values are in ascending or in descending order respectively, otherwise output 0.

Series39. An integer K and K sequences of nonzero integers are given. Each given sequence contains at least three elements and is terminated by zero, which is not an element of the sequence. Output the amount of the sawtooth sequences (see the definition of a sawtooth sequence in Series23).

Series40. An integer K and K sequences of nonzero integers are given. Each given sequence contains at least three elements and is terminated by zero, which is not an element of the sequence. Process each sequence as follows: output its length if the sequence is a sawtooth one (see Series23), otherwise output the order number of its first element that is not a tooth.


PrevNext

 

  @Mail.ru

Designed by
M. E. Abramyan and V. N. Braguilevsky

Last revised:
06.05.2018