You are not logged in. Please login at www.codechef.com to post your questions!

×

KCC02 - EDITORIAL

DIFFICULTY: SIMPLE

PREREQUISITES: Modulus Operator

Problem:

 We are provided with a pattern of N numbers and have to find the output for each number of that sequence.

Quick Explanation:

 If we look closely we can easily find that the output of each element of the sequence is the sum of divisors of that number excluding itself.

Explanation:

 The output for each input number is the sum of its divisors exluding that number and it can be computed easily by checking for number i in range 1<=i<N.
 Result can be computed in O(N) time.

 Pseudo Code:

      sum=0;
      for i form 1 to N-1 :
         if N%i==0 :
            sum = sum+i;
         end if 
      end for
      return sum;

Time Complexity : O(T*N);

Editorialist's Solution: Can be found here.

This question is marked "community wiki".

asked 18 Mar '18, 18:53

abhi55's gravatar image

4★abhi55
426
accept rate: 5%

edited 21 Mar '18, 15:31

admin's gravatar image

0★admin ♦♦
19.8k350498541

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,191
×303
×13
×3

question asked: 18 Mar '18, 18:53

question was seen: 134 times

last updated: 21 Mar '18, 15:31