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

×

RIO3 - Editorial

PROBLEM LINK:

Practice

Author: Vishal Khopkar

DIFFICULTY:

EASY

PREREQUISITES:

None

PROBLEM:

We are given two numbers i and j and a number 'n', and our aim is to find all numbers less than or equal to n which are either i or j or obtained from the sum of the given numbers. For example,

n=20

i=2, j=5

The output will contain 2, 5, 2+5=7, 7+2=9, 9+2=11, 7+5=12, 11+2=13, 9+5=14, 13+2=15, 11+5=16, 15+2=17, 13+5=18, 14+5=19, 15+5=20

EXPLANATION:

If the two numbers i, j are co-prime, then we need to find all numbers upto their product because all numbers ahead would anyways be a part of the output. Similarly, if one number is a multiple of the other, the solution contains all the multiples of the smaller number upto 'n'. In this way, you need to find ways so that you can get to the solution faster.

SOLUTION

Solution

asked 08 Nov '16, 11:44

abhirajphadnis's gravatar image

0★abhirajphadnis
42
accept rate: 0%

edited 29 Mar '17, 12:51

admin's gravatar image

0★admin ♦♦
19.0k348495531

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:

×14,361
×52
×34
×1

question asked: 08 Nov '16, 11:44

question was seen: 342 times

last updated: 29 Mar '17, 12:51