#C13391. Playlist Property Checker
Playlist Property Checker
Playlist Property Checker
Given a playlist consisting of song durations, determine whether the playlist satisfies the following property:
For every group of three consecutive songs, the sum of their durations must be divisible by the duration of the first song in that group. Formally, let the playlist be represented as an array \(a_1, a_2, \dots, a_n\). For every valid index \(i\) such that \(1 \le i \le n-2\), it must hold that:
\[ a_i \mid (a_i + a_{i+1} + a_{i+2}). \]
If the playlist contains fewer than three songs, the property is considered to be satisfied.
Write a program that reads from standard input the number of songs followed by the durations of the songs and prints True
if the playlist satisfies the property and False
otherwise.
inputFormat
The input is given in two lines. The first line contains a single integer \(n\) (\(1 \le n \le 10^5\)) representing the number of songs. The second line contains \(n\) space-separated integers representing the durations of the songs.
outputFormat
Output a single line containing either True
or False
(without quotes) indicating whether the playlist satisfies the property.
6
3 6 9 3 6 9
True
</p>