Server Side Programming Articles - Page 570 of 2651

C++ program to construct graph with certain conditions

Arnab Chakraborty
Updated on 03-Mar-2022 06:55:06

577 Views

Suppose we have two numbers N and K. Consider there is an undirected graph with N elements. N vertices satisfies the following conditions −The graph is simple and connectedVertices are numbered from 1 to NLet M be the number of edges in the graph. The edges are numbered from 1 to M. The length of the edge is 1. And Edge i connects vertex U[i] to vertex V[i].There are exactly K pairs of vertices (i, j) where i < j, such that the shortest distance between them is 2.If such graph exists, we have to construct that graph. Otherwise return ... Read More

C++ program to find winner of cell coloring game

Arnab Chakraborty
Updated on 03-Mar-2022 06:51:20

595 Views

Suppose we have two arrays A and B both are with N elements each. Consider Amal and Bimal are playing a game on a board whose cell numbers are numbered from 1 to N. And N-1 roads. Roads are connecting two cells. So ith road is connecting A[i] to B[i]. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. Initially the cell 1 is marked as black color, and cell N is white. Other cells are not colored. Amal plays first, and they are playing alternatively. Amal selects an uncolored cells that is ... Read More

C++ program to find nearest integer for which the number and its digits sum gcd is greater than 1

Arnab Chakraborty
Updated on 03-Mar-2022 06:52:03

229 Views

Suppose we have a number N. Consider a function gcdSum(x) of a positive integer x which is the gcd of that integer with its sum of digits. We have to find the smallest integer x >= n, such that gcdSum(x) > 1.So, if the input is like N = 31, then the output will be 33, because gcd of 31 and (3+1) is 1. The gcd of 32 and (3+2) is 1, and gcd of 33 and (3+3) is 3.StepsTo solve this, we will follow these steps −for initialize i := n, when i 0, do:       ... Read More

Differentiate a Laguerre series with multidimensional coefficients in Python

AmitDiwan
Updated on 03-Mar-2022 06:48:13

138 Views

To differentiate a Laguerre series, use the laguerre.lagder() method in Python. The method returns the Laguerre series coefficients c differentiated m times along axis. At each iteration the result is multiplied by scl. The argument c is an array of coefficients from low to high degree along each axis, e.g., [1, 2, 3] represents the series 1*L_0 + 2*L_1 + 3*L_2 while [[1, 2], [1, 2]] represents 1*L_0(x)*L_0(y) + 1*L_1(x)*L_0(y) + 2*L_0(x)*L_1(y) + 2*L_1(x)*L_1(y) if axis=0 is x and axis=1 is y.The 1st parameter, c is an array of Laguerre series coefficients. If c is multidimensional the different axis correspond ... Read More

C++ program to find in how many bases we can represent the number not greater than M

Arnab Chakraborty
Updated on 03-Mar-2022 06:48:09

180 Views

Suppose we have a numeric string S, and another number M. Let d be the greatest digit in S. We have to find in many different integers not greater than M can be found by choosing an integer n not less than d+1 and seeing S as a base-n number?So, if the input is like S = "999"; M = 1500, then the output will be 3, because S as base 10 number, we get 999, as base 11 number, we get 1197, as base 12 number, we get 1413. These three values are the only ones that we can ... Read More

Differentiate a Laguerre series in Python

AmitDiwan
Updated on 03-Mar-2022 06:46:08

139 Views

To differentiate a Laguerre series, use the laguerre.lagder() method in Python. The method returns the Laguerre series coefficients c differentiated m times along axis. At each iteration the result is multiplied by scl. The argument c is an array of coefficients from low to high degree along each axis, e.g., [1, 2, 3] represents the series 1*L_0 + 2*L_1 + 3*L_2 while [[1, 2], [1, 2]] represents 1*L_0(x)*L_0(y) + 1*L_1(x)*L_0(y) + 2*L_0(x)*L_1(y) + 2*L_1(x)*L_1(y) if axis=0 is x and axis=1 is y.The 1st parameter, c is an array of Laguerre series coefficients. If c is multidimensional the different axis correspond ... Read More

Evaluate a 3-D Laguerre series on the Cartesian product of x, y and z with 2d array of coefficient in Python

AmitDiwan
Updated on 03-Mar-2022 06:44:23

169 Views

To evaluate a 3-D Laguerre series on the Cartesian product of x, y and z, use the polynomial.laguerre.laggrid3d() method in Python. The method returns the values of the three dimensional Laguerre series at points in the Cartesian product of x, y and z.If c has fewer than three dimensions, ones are implicitly appended to its shape to make it 3-D. The shape of the result will be c.shape[3:] + x.shape + y.shape + z.shape. The 1st parameter, x, y, z are the three dimensional series is evaluated at the points in the Cartesian product of x, y, and z. If ... Read More

C++ program to find longest possible time not greater than T to solve all problems

Arnab Chakraborty
Updated on 03-Mar-2022 06:44:35

264 Views

Suppose we have an array A with N elements. Have another number T. Consider Amal is trying to participate in a programming contest. It lasts for T minutes and present N problems. He has A[i] time to solve ith problem. He will choose zero or more problems to solve from the N problems, so that it takes no longer T minutes in total to solve them. We have to find the longest possible time it will take to solve his choice of problems.So, if the input is like T = 17; A = [2, 3, 5, 7, 11], then the ... Read More

Evaluate a 2-D Laguerre series on the Cartesian product of x and y with 3d array of coefficient in Python

AmitDiwan
Updated on 03-Mar-2022 06:41:38

162 Views

To evaluate a 2-D Laguerre series on the Cartesian product of x and y, use the polynomial.laguerre.laggrid2d() method in Python. The method returns the values of the two dimensional Laguerre series at points in the Cartesian product of x and y.If c has fewer than two dimensions, ones are implicitly appended to its shape to make it 2-D. The shape of the result will be c.shape[2:] + x.shape + y.shape. The 1st parameter, x, y is the two dimensional series is evaluated at the points in the Cartesian product of x and y. If x or y is a list ... Read More

C++ program to count final number of characters are there after typing n characters in a crazy writer

Arnab Chakraborty
Updated on 03-Mar-2022 06:47:47

158 Views

Suppose we have an array A with n elements, and another value c is there. There is a crazy word processor present in our system where we can type characters but if we do not type for consecutive c seconds, all of the written letters will be removed. A[i] represents the time when we have typed the ith character. We have to find the final number of characters that will remain on the screen after typing all n characters.So, if the input is like A = [1, 3, 8, 14, 19, 20]; c = 5, then the output will be ... Read More

Advertisements