

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ code to find pair of numbers where one is multiple of other
Suppose we have two numbers l and r. We have to find such pair (x, y), such that l <= x, y <= r, and x != y and x divides y. If there are more than one answer, return any one of them.
So, if the input is like l = 3; r = 14, then the output will be (3, 9).
Steps
To solve this, we will follow these steps −
return l and l*2
Example
Let us see the following implementation to get better understanding −
#include <bits/stdc++.h> using namespace std; void solve(int l, int r){ cout << l << ", " << l * 2; } int main(){ int l = 3; int r = 14; solve(l, r); }
Input
3, 14
Output
3, 6
- Related Questions & Answers
- Program to find length of the largest subset where one element in every pair is divisible by other in Python
- Check if one of the numbers is one’s complement of the other in Python
- Program to count number of valid pairs from a list of numbers, where pair sum is odd in Python
- Sum of two numbers where one number is represented as array of digits in C++
- Program to find maximum size of any sequence of given array where every pair is nice in Python
- C++ Program to Find k Numbers Closest to Median of S, Where S is a Set of n Numbers
- Find indices of all occurrence of one string in other in C++
- C++ code to find index where this is a hash collision
- C++ code to find string where trygub is not a substring
- Find document in MongoDB where at least one item from an array is not in the other?
- Program to find longest number of 1s after swapping one pair of bits in Python
- Program to find smallest pair sum where distance is not consecutive in Python
- Program to find number of ways where square of number is equal to product of two numbers in Python
- Check if one list is subset of other in Python
- Check if one tuple is subset of other in Python
Advertisements