Friend numbers P97058


Statement
 

pdf   zip

html

Two numbers are called friends if they are different and the sum of the divisors of each number (including 1, but excluding the own number) is equal to the other number.

For instance, 2620 and 2924 are friends: 2620 is divisible by 1, 2, 4, 5, 10, 20, 131, 262, 524, 655 and 1310; that sum 2924. 2924 is divisible by 1, 2, 4, 17, 34, 43, 68, 86, 172, 731 and 1462; that sum 2620.

Write a program that prints if pairs of numbers are friends.

Input

Input is a sequence of pairs of natural numbers a, b with 2≤ a <b.

Output

For each pair a, b of the input, print if they are friends or are not according to the format of the example.

Observation

This problem is from “The British Informatics Olympiad for schools and colleges”.

Public test cases
  • Input

    2620 2924
    333 666
    365 366
    

    Output

    2620 and 2924 are friends
    333 and 666 are not friends
    365 and 366 are not friends
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++