Found 7347 Articles for C++

Find the Number of Solution to Modular Equations using C++

Prateek Jangid
Updated on 24-Nov-2021 12:13:08

169 Views

In this article we will explain everything about what is the solution of modular equations, also we will write a program to find a number of solutions to modular equations. So here is the basic example −Input : X = 30 Y = 2 Output : 4, 7, 14, 28 Explanation : 30 mod 4 = 2 (equals Y),    30 mod 7 = 2 (equals Y),    30 mod 14 = 2 (equals Y),    30 mod 28 = 2 (equals Y) Input : X = 30 Y = 2 Output : 4, 7, 14, 28 Explanation : 30 ... Read More

Find the Number of Solutions of n = x + n x using C++

Prateek Jangid
Updated on 24-Nov-2021 12:09:50

164 Views

In this article we are going to find number of solution of equation n = x + n ⊕ x, i.e we need to find number of values of x possible with given value n such that n = x + n ⊕ x where ⊕ represents XOR operation.Now we will discuss the complete information regarding number of solutions of n = x + n ⊕ x with an appropriate examples.Brute Force MethodWe can simple use brute force approach in order to find number of solution, i.e for given value of n we apply every integer value of x starting ... Read More

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

Prateek Jangid
Updated on 24-Nov-2021 12:06:35

220 Views

In this article, we will explain the approaches to find the number of solutions for the equation x+y+z

Find the Number of Sink Nodes in a Graph using C++

Prateek Jangid
Updated on 24-Nov-2021 12:04:19

223 Views

In this article, we will describe the important information on solving the number of sinks nodes in a graph. We have a Directed Acyclic Graph with N nodes (1 to N) and M edges in this problem. The goal is to find how many sink nodes are there in the given graph. A sink node is a node that does not produce any outgoing edges. So here is a simple example −Input : n = 4, m = 2 Edges[] = {{2, 3}, {4, 3}} Output : 2Simple Approach to Find the SolutionIn this approach, we will go through ... Read More

Find the Number of Siblings of a Given Node in N-ary Tree using C++

Prateek Jangid
Updated on 24-Nov-2021 12:02:24

144 Views

In this article, we will provide complete information to determine the number of siblings of a given node in the n-ary tree. We need to find the node's siblings with the value of key as given by the user; if it is non, then output as -1. There is only one approach that we can use −Simple ApproachIn this approach, we will go through all the nodes and check if a child has the same value as the user. If it exists, we answer a number of children - 1(the given value).Example #include using namespace std; class Node { ... Read More

Find the Number of segments where all elements are greater than X using C++

Prateek Jangid
Updated on 24-Nov-2021 11:34:22

231 Views

In this article, we have to find the number of segments or subarrays in a given sequence where elements greater than the given number X.We can count overlapping segments only once, and two contiguous elements or segments should not count separately. So here is the basic example of the given problem −Input : arr[ ] = { 9, 6, 7, 11, 5, 7, 8, 10, 3}, X = 7 Output : 3 Explanation : { 9 }, { 11 } and { 8, 10 } are the segments greater than 7 Input : arr[ ] = { 9, 6, ... Read More

Find the Number of Reflexive Relations on a Set using C++

Prateek Jangid
Updated on 24-Nov-2021 11:20:05

404 Views

In this article, we will explain the approaches to find the number of reflexive relations on a set. In this problem, we are given with number n, and on a set of n natural numbers, we must determine the number of reflexive relations.Reflexive Relation − A relation in a set A is called reflexive if ( a, a ) belongs to R for every 'a' belongs to set A. For example −Input : x = 1 Output : 1 Explanation : set = { 1 }, reflexive relations on A * A : { { 1 } } Input ... Read More

Find the Number of quadruples where the first three terms are in AP and last three terms are in GP using C++

Prateek Jangid
Updated on 24-Nov-2021 11:16:28

87 Views

In this article, we will describe every possible approach to find the number of quadruples in which the first 3 terms are in A.P., and the last 3 are in G.P. First, we will explain the basic definition of arithmetic progression(A.P.) and geometric progression (G.P.).Arithmetic progression(A.P.) − It is a sequence of numbers in which the common difference (d) is the same or constant that means a difference of two consecutive numbers is constant. For example: 1, 3, 5, 7, 9 | d = 2Geometric Progression(G.P.) − It is a sequence of numbers in which the common ratios (r) are ... Read More

Find the Number of Quadrilaterals Possible from the Given Points using C++

Prateek Jangid
Updated on 24-Nov-2021 11:12:38

340 Views

A quadrilateral forms a polygon with four vertices and four edges in Euclidean plane geometry. The name 4-gon etc. Included in other names of quadrilaterals and sometimes they are also known as a square, display style, etc.In this article, we will explain the approaches to finding the number of quadrilaterals possible from the given points. In this problem, we need to find out how many possible quadrilaterals are possible to create with the provided four points ( x, y ) in the cartesian plane. So here is the example for the given problem −Input : A( -2, 8 ), B( ... Read More

Find the Number of Primes In A Subarray using C++

Prateek Jangid
Updated on 24-Nov-2021 11:08:25

174 Views

In this article we will describe the ways to find the number of primes in a subarray. We have an array of positive numbers arr[] and q queries having two integers that denote our range {l, R} we need to find the number of primes in the given range. So below is an example of the given problem −Input : arr[] = {1, 2, 3, 4, 5, 6}, q = 1, L = 0, R = 3 Output : 2 In the given range the primes are {2, 3}. Input : arr[] = {2, 3, 5, 8 ... Read More

Advertisements