Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Bibi has always been fascinated by numbers. Currently, she is researching the correlation between a number and the sum of its divisors. A number K

Bibi has always been fascinated by numbers. Currently, she is researching the correlation between a number and the sum of its divisors. A number K is a divisor of X if K

fully divides X and leaves no remainder. The number 6 for example, has a sum of 12

which comes from 1 + 2 + 3 + 6. To speed up her research, she has asked your help as

her programmer friend to help create a program that can sort an array of numbers A

ascendingly based on the sum of its divisors. In case of a tie, she has asked you to output

the smaller number before the larger number.

Format Input

A single line with an integer N denoting the number of elements followed by another line

containing N elements denoting the numbers in the array.

Format Output

A single line with N elements separated by a single space denoting the sorted array

satisfying Bibis requirements.

Constraints

1 N 10^3

1 Ai 10^4

Each element in A does not appear more than once

Sample Input 1

5

1 13 6 7 2

Sample Output 1

1 2 7 6 13

Sample Input 2

10

1 2 3 4 5 6 7 8 9 10

Sample Output 2

1 2 3 5 4 7 6 9 8 10

Note : Use C Language , Dont Use Stdlib as you can

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago