300521: CF100B. Friendly Numbers
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
B. Friendly Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
Kiana thinks two integers are friends if and only if one of them divides the other one. For example, 12 and 4 are friends, also 6 and 6 are friends too, but 120 and 36 are not.
A group of non-zero integers is called friendly, if each pair of its integers form a friend pair.
You are given a group of non-zero integers. See if they're friendly.
InputThe first line contains n (1 ≤ n ≤ 1000), where n — the number of integers in the group.
The next line contains the elements, sorted in the non-decreasing order. The numbers are comma separated, they have at most 7 digits in their decimal notation and do not have any leading zeros.
OutputIf the group is friendly write "FRIENDS", else write "NOT FRIENDS".
ExamplesInput4Output
1,3,6,12
FRIENDSInput
3Output
1,2,9
NOT FRIENDS