Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Divisor Sort

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

How can user view performance model of KNN model?

Answered: 1 week ago

Question

Find the derivative. f(x) 8 3 4 mix X O 4 x32 4 x32 3 -4x - x2

Answered: 1 week ago

Question

Which of these influenced your life most dramatically?

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago