Find Four Factors of n with Maximum Product and Sum Equal to n in C++

Arnab Chakraborty
Updated on 24-Jul-2020 11:01:57

117 Views

ConceptWith respect of a given integer N, our task is to determine all factors of N and print the product of four factors of N so that −The sum of the four factors is equal to N.The product of the four factors is largest.It has been seen that if it is impossible to determine 4 such factors then print “Not possible”. It should be noted thatall the four factors can be equal to each other to maximize the product.InputN = 60OutputAll the factors are -> 1 2 3 4 5 6 10 12 15 20 30 60 Product is -> ... Read More

Find First Element in AP Which is Multiple of Given Prime in C++

Arnab Chakraborty
Updated on 24-Jul-2020 10:58:32

75 Views

ConceptWith respect of given first term (A) and common difference (d) of an Arithmetic Progression, and a prime number (P), our task is to determine the position of the first element in the given AP which is treated as a multiple of the given prime number P.InputA = 3, d = 4, P = 5Output3ExplanationThe fourth term of the given AP is a multiple of prime number 5.First Term = 3Second Term = 3+4 = 7Third Term = 3+2*4 = 11Fourth Term = 3+3*4 = 15MethodAssume the term be AN. As a result of this, AN = (A + (N-1)*d)So, ... Read More

Find Element Position in Given Monotonic Sequence in C++

Arnab Chakraborty
Updated on 24-Jul-2020 10:57:31

269 Views

ConceptWith respect of a given integer l and a monotonic increasing sequence −f(m) = am + bm [log2(m)] + cm^3 where (a = 1, 2, 3, …), (b = 1, 2, 3, …), (c = 0, 1, 2, 3, …) Remember, here, [log2(m)] indicates, taking the log to the base 2 and round the value down.As a result of this, if m = 1, the value is 0.if m = 2-3, the value is 1.if m = 4-7, the value is 2.if m = 8-15, the value is 3.Our task is to determine the value m such that f(m) = ... Read More

Find Duplicates of Array Using Bit Array in C++

Arnab Chakraborty
Updated on 24-Jul-2020 10:48:52

377 Views

ConceptWe have an array of n numbers, where n is maximum 32, 000. Now the given array may have duplicate entries and we do not know what n is. Now the question is arisen that with only4 Kilobytes of memory available, how would display or print all duplicates elements in the array?Inputarr[] = {2, 6, 2, 11, 13, 11}Output2 11 2 and 11 appear more than once in given array.Inputarr[] = {60, 50, 60}Output60MethodsNow we have 4 Kilobytes of memory which indicates we can address up to 8 * 4 * 210 bits.It should be noted that 32 * 210 ... Read More

Find Distinct Elements Common to All Rows of a Matrix in C++

Arnab Chakraborty
Updated on 24-Jul-2020 10:48:04

284 Views

ConceptWith respect of a given an m x m matrix, the problem is to determine all the distinct elements common to all rows of the matrix. So the elements can be displayed in any order.Inputmat[][] = { {13, 2, 15, 4, 17}, {15, 3, 2, 4, 36}, {15, 2, 15, 4, 12}, {15, 26, 4, 3, 2}, {2, 19, 4, 22, 15} }Output2 4 15MethodsFirst Method: Implement three nested loops. Verify if an element of 1st row is present in all the subsequent rows. Here, time Complexity is O(m^3). Additional space could be required to control the duplicate elements.Second Method: ... Read More

Maximize Number of Zeros in Array C in C++

Arnab Chakraborty
Updated on 24-Jul-2020 10:43:49

183 Views

ConceptWith respect of two given arrays of M integers, assume an array C, where the i-th integer will be d*a[i] + b[i] where d is indicated as any arbitrary real number. Our task is to display or print d such that array C has largest number of zeros and also prints the number of zeros.Inputa[] = {15, 40, 45} b[] = {4, 5, 6}OutputValue of d is: -0.133333 The number of zeros in array C is: 1 If we choose d as -0.133333 then we get one zero in the array C which is the maximum possible.MethodsWe follow the below ... Read More

Find Combined Mean and Variance of Two Series in C++

Arnab Chakraborty
Updated on 24-Jul-2020 10:40:50

148 Views

ConceptWith respect of two given two different series arr1[b] and arr2[a] of size b and a. Our task is to determine the mean and variance of combined series.InputArr1[] = { 24, 46, 35, 79, 13, 77, 35 }; Arr2[] = { 66, 68, 35, 24, 46 };OutputMean1: 44.1429 Mean2: 47.8 StandardDeviation1: 548.694 StandardDeviation2: 294.56 Combined Mean: 45.6667 d1 square: 2.322 d2_square: 4.5511 Combined Variance: 446.056MethodNow suppose, n1= No. of observations in 'region 1'n2= No. of observations in 'region 1'X1= mean of region 1.X2=mean of region 2.S1=standard deviation of region 1.S2=standard deviation of region 2.S12 = variance of region 1.S22 = ... Read More

Use Timeout Parameter in Restart-Computer Cmdlet in PowerShell

Chirag Nagrekar
Updated on 24-Jul-2020 10:36:28

1K+ Views

As the name describes, with –Timeout parameter, you can restrict time for validations (PowerShell, WinRM, and WMI connectivity check after reboot) for –Wait and –For parameters and if the checks don’t complete during that time then it returns an error. This timeout value is in seconds. You can specify this parameter with either –Wait or –For parameter but with –For parameter you need to include –Wait parameter as well.When -Timeout is specified with –Wait parameter, the overall checks (3 validations: PowerShell, WMI, and WINRM connectivity) then overall check time is restricted in seconds and when it is used with –For ... Read More

Use For Parameter in Restart-Computer Cmdlet in PowerShell

Chirag Nagrekar
Updated on 24-Jul-2020 10:35:30

310 Views

In the –Wait parameter 3 main checks are validated − PowerShell, WMI, and WINRM connectivity. So whenever you specify the –Wait parameter, you have to wait until all three checks pass, however, if any of the checks fail then script freezes and can not further execute. If you know which specific check you want to perform then you can specify that value with the –For parameter as shown below.Here, for the example, we will run a single WMI check for the remote server.Restart-Computer Test1-Win2k12 -Wait -For Wmi -Force-For parameter must be used with –Wait parameter. Here, again if something goes ... Read More

Use Wait Parameter in Restart-Computer Cmdlet in PowerShell

Chirag Nagrekar
Updated on 24-Jul-2020 10:33:36

2K+ Views

When we use Restart-Computer command with the remote computer names, PowerShell restarts the mentioned remote computers without any checks or validations if the server has come up or not. This requirement is fulfilled with the - Wait parameter. Whenever the - Wait parameter specified, PowerShell performs the below 3 checks on the remote computer when the computer is restarting.This can be noticed in the Progress bar of the PowerShell console.PowerShell − If the computer can run the Powershell command on the remote machine.WMI − Performs the WMI query on the remote computer using the Win32_ComputerSystem command.WINRM − Checks the remote ... Read More

Advertisements