#C7420. Multiple Pair Detection
Multiple Pair Detection
Multiple Pair Detection
You are given a list of positive integers. Your task is to determine whether there exist two distinct integers such that one is a multiple of the other. Formally, given a list \(a_1, a_2, \dots, a_n\), check if there exist indices \(i \neq j\) such that \(a_i \mid a_j\) or \(a_j \mid a_i\). If such a pair exists, print YES
; otherwise, print NO
.
For example, if the input is 10 5 3 15 20
, then 5
divides 10
(and also appears in the list), so the answer is YES
. Conversely, if the input is 7 11 13 17
, there is no pair satisfying the condition, so the output should be NO
.
inputFormat
The first line contains an integer \(n\) representing the number of elements. The second line contains \(n\) space-separated positive integers \(a_1, a_2, \dots, a_n\).
outputFormat
Output a single line containing either YES
if there exists a pair where one number is a multiple of the other, or NO
otherwise.
5
10 5 3 15 20
YES