codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

100B.md (1032B)


      1 Source: https://codeforces.com/problemset/problem/100/B
      2 
      3 B. Friendly Numbers
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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.
     22 
     23 A group of non-zero integers is called friendly, if each pair of its integers form a friend pair.
     24 
     25 You are given a group of non-zero integers. See if they're friendly.
     26 
     27 Input
     28 
     29 The first line contains *n* (1 ≤ *n* ≤ 1000), where *n* — the number of integers in the group.
     30 
     31 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.
     32 
     33 Output
     34 
     35 If the group is friendly write "FRIENDS", else write "NOT FRIENDS".
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 4  
     43 1,3,6,12
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 FRIENDS
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 3  
     56 1,2,9
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 NOT FRIENDS
     63 ```