Math, asked by khushimaity12, 5 months ago

List all the element of the following set.

A={x: x is an integer, x2 ≤ 16}​

Answers

Answered by sajjanjakhar381
3

Step-by-step explanation:

GEEKSFORGEEKS

Number of solutions for x < y, where a <= x <= b and c <= y <= d and x, y are integers

Given four integers a, b, c, d ( upto 10^6 ). The task is to Find the number of solutions for x < y, where a <= x <= b and c <= y <= d and x, y integers.

Examples:

Input: a = 2, b = 3, c = 3, d = 4

Output: 3

Input: a = 3, b = 5, c = 6, d = 7

Output: 6

Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach: Let’s iterate explicitly over all possible values of x. For one such fixed value of x, the problem reduces to how many values of y are there such that c <= y <= d and x = max(c, x + 1) and y <= d. Let’s assume that c <= d, otherwise, there are no valid values of y of course. It follows, that for a fixed x, there are d – max(c, x+1) + 1 valid values of y because the number of integers in a range [R1, R2] is given by R2 – R1 + 1.

Below is the implementation of the above approach:

// C++ implementation of above approach

#include <bits/stdc++.h>

using namespace std;

// function to Find the number of solutions for x < y,

// where a <= x <= b and c <= y <= d and x, y integers.

int NumberOfSolutions(int a, int b, int c, int d)

{

// to store answer

int ans = 0;

// iterate explicitly over all possible values of x

for (int i = a; i <= b; i++)

if (d >= max(c, i + 1))

ans += d - max(c, i + 1) + 1;

// return answer

return ans;

}

// Driver code

int main()

{

int a = 2, b = 3, c = 3, d = 4;

// function call

cout << NumberOfSolutions(a, b, c, d);

return 0;

}

Output:

3

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

Recommended Posts:

Find number of solutions of a linear equation of n variables

Number of non-negative integral solutions of a + b + c = n

Count number of solutions of x^2 = 1 (mod p) in given range

Number of integral solutions of the equation x1 + x2 +.... + xN = k

Number of non-negative integral solutions of sum equation

Number of solutions to Modular Equations

Number of integral solutions for equation x = b*(sumofdigits(x)^a)+c

Program to find number of solutions in Quadratic Equation

Find 'N' number of solutions with the given inequality equations

Number of solutions of n = x + n ⊕ x

Number of solutions for the equation x + y + z <= n

Find the number of solutions to the given equation

Median in a stream of integers (running integers)

Mode in a stream of integers (running integers)

Lexicographically smallest permutation of size A having B integers exceeding all preceeding integers

Drishti-Soft Solutions Interview | Set 1

Python | Finding Solutions of a Polynomial Equation

0/1 Knapsack Problem to print all possible solutions

Find the number of integers x in range (1,N) for which x and x+1 have same number of divisors

Count of integers in a range which have even number of odd digits and odd number

hope my answer is correct

Similar questions