×

# RIO3 - Editorial

Author: Vishal Khopkar

EASY

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

42
accept rate: 0%

19.3k348495534

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×15,010
×53
×37
×1

question asked: 08 Nov '16, 11:44

question was seen: 383 times

last updated: 29 Mar '17, 12:51