# Tag Archives: combionatrics

## Sum of all possible triplet products from given ranges

Given three integers A, B and C, the task is to find the value of the expression  Since the answer can be very large, print… Read More »

## Count pairs whose product contains single distinct prime factor

Given an array arr[] of size N, the task is to count the number of pairs from the given array whose product contains only a… Read More »

## Find an integral solution of the non-linear equation 2X + 5Y = N

Given an integer N representing a non-linear equation of the form 2X + 5Y = N, the task is to find an integral pair (X,… Read More »

## Count unique paths with given sum in an N-ary Tree

Given an integer X and integer N, the task is to find the number of unique paths starting from the root in N-ary tree such… Read More »

## Probability of obtaining Prime Numbers as product of values obtained by throwing N dices

Given an integer N denoting the number of dices, the task is to find the probability of the product of numbers appearing on the top… Read More »

## Count permutations of all integers upto N that can form an acyclic graph based on given conditions

Given an integer N, the task is to find the number of permutations of integers from the range [1, N] that can form an acyclic… Read More »

## Number of pairs whose product is a power of 2

Given an array arr[] consisting of N integers, the task is to count the total number of pairs of array elements from the given array… Read More »

## Count possible splits of sum N into K integers such that the minimum is at least P

Given three integers N, P, and K, the task is to find the total number of ways to divide N into K integers having sum… Read More »

## Count ways to place all the characters of two given strings alternately

Given two strings, str1 of length N and str2 of length M of distinct characters, the task is to count the number of ways to… Read More »

## Count of all possible ways to reach a target by a Knight

Given two integers N, M denoting N×M chessboard, the task is to count the number of ways a knight can reach (N, M) starting from… Read More »

## Number of ways to select exactly K even numbers from given Array

Given an array arr[] of n integers and an integer K, the task is to find the number of ways to select exactly K even… Read More »

## Count ways to reach Nth Stairs by taking 1 and 2 steps with exactly one 3 step

Given a number N which denotes the number of stairs, the task is to reach the Nth stair by taking 1, 2 steps any number… Read More »

## Random Tree Generator Using Prüfer Sequence with Examples

Given an integer N, the task is to generate a random labelled tree of N node with (N – 1) edges without forming cycle. Note:… Read More »

## Puzzle | 1000 light bulbs switched on/off by 1000 persons passing by

There are 1000 light bulbs and 1000 persons. All light bulbs are initially off. Person 1 goes flipping light bulb 1, 2, 3, 4, …… Read More »

## Sum of the products of all possible Subsets

Given an array of n non-negative integers. The task is to find the sum of the product of elements of all the possible subsets. It… Read More »