15,920,217 members
Home / Discussions / C / C++ / MFC

# C / C++ / MFC

 Re: problem understanding a functionality of constructor. Jochen Arndt27-Mar-18 4:55 Jochen Arndt 27-Mar-18 4:55
 Re: problem understanding a functionality of constructor. Richard MacCutchan27-Mar-18 5:18 Richard MacCutchan 27-Mar-18 5:18
 Re: problem understanding a functionality of constructor. CPallini27-Mar-18 5:36 CPallini 27-Mar-18 5:36
 Hackerrank:Down to Zero problem SrinivasaRamanujan25-Mar-18 10:23 SrinivasaRamanujan 25-Mar-18 10:23
 Problem statement: You are given Q queries. Each query consists of a single number N. You can perform any of the 2 operations on in each move: 1: If we take 2 integers a and b where N=aXb(a!=1,b!=1) then we can change N=max(a,b). 2: Decrease the value of N by 1. Determine the minimum number of moves required to reduce the value of N to 0 Input Format The first line contains the integer Q. The next Q lines each contain an integer,N . Output Format Output Q lines. Each line containing the minimum number of moves required to reduce the value of N to 0. Sample Input 2 3 4 Sample Output 3 3 Explanation For test case 1, We only have one option that gives the minimum number of moves. Follow 3->2 -> 1->0 . Hence, 3 moves. For the case 2, we can either go 4->3 ->2 ->1 ->0 or4 -> 2-> 1->0 . The 2nd option is more optimal. Hence, 3 moves. My algo: if a number is N then I do looping until sqrt(N) to find if it is a prime or not. if it is a prime number then N=N-1 if it not a prime number,one of the largest factor(say a) is <=sqrt(N) then other will be b=N/a now b>a then put N=b; increment count(pass by value). then next iteration for N ,until it is greater than 1. return count. algorithms works fine with small value but predicts less optimal solution for large values.why?
 Re: Hackerrank:Down to Zero problem David Crow25-Mar-18 15:41 David Crow 25-Mar-18 15:41
 In type conversion of 2 different classes can i convert both ways ? Tarun Jha25-Mar-18 5:14 Tarun Jha 25-Mar-18 5:14
 Re: In type conversion of 2 different classes can i convert both ways ? Victor Nijegorodov25-Mar-18 8:07 Victor Nijegorodov 25-Mar-18 8:07
 Re: In type conversion of 2 different classes can i convert both ways ? Tarun Jha25-Mar-18 23:26 Tarun Jha 25-Mar-18 23:26
 Re: In type conversion of 2 different classes can i convert both ways ? CPallini25-Mar-18 10:50 CPallini 25-Mar-18 10:50
 Re: In type conversion of 2 different classes can i convert both ways ? Tarun Jha25-Mar-18 23:25 Tarun Jha 25-Mar-18 23:25
 Re: In type conversion of 2 different classes can i convert both ways ? CPallini26-Mar-18 0:18 CPallini 26-Mar-18 0:18
 Adding two matrix objects and assigning the result to third object using overloaded operators ? Tarun Jha24-Mar-18 8:19 Tarun Jha 24-Mar-18 8:19
 Re: Adding two matrix objects and assigning the result to third object using overloaded operators ? Victor Nijegorodov24-Mar-18 8:35 Victor Nijegorodov 24-Mar-18 8:35
 Re: Adding two matrix objects and assigning the result to third object using overloaded operators ? Tarun Jha24-Mar-18 10:06 Tarun Jha 24-Mar-18 10:06
 Re: Adding two matrix objects and assigning the result to third object using overloaded operators ? Richard MacCutchan24-Mar-18 21:13 Richard MacCutchan 24-Mar-18 21:13
 Re: Adding two matrix objects and assigning the result to third object using overloaded operators ? Tarun Jha25-Mar-18 5:08 Tarun Jha 25-Mar-18 5:08
 Re: Adding two matrix objects and assigning the result to third object using overloaded operators ? Richard MacCutchan25-Mar-18 5:32 Richard MacCutchan 25-Mar-18 5:32
 Re: Adding two matrix objects and assigning the result to third object using overloaded operators ? Tarun Jha25-Mar-18 6:37 Tarun Jha 25-Mar-18 6:37
 Re: Adding two matrix objects and assigning the result to third object using overloaded operators ? Richard MacCutchan25-Mar-18 7:16 Richard MacCutchan 25-Mar-18 7:16
 Re: Adding two matrix objects and assigning the result to third object using overloaded operators ? Tarun Jha25-Mar-18 8:06 Tarun Jha 25-Mar-18 8:06
 Linux C++ implementation of ioctl SOLVED Vaclav_23-Mar-18 8:50 Vaclav_ 23-Mar-18 8:50
 Re: Linux C++ implementation of ioctl Jochen Arndt24-Mar-18 23:39 Jochen Arndt 24-Mar-18 23:39
 Re: Linux C++ implementation of ioctl leon de boer26-Mar-18 16:53 leon de boer 26-Mar-18 16:53
 Re: Linux C++ implementation of ioctl Vaclav_4-Apr-18 5:08 Vaclav_ 4-Apr-18 5:08
 VS2017: Cannot debug Dll's indrekm23-Mar-18 1:13 indrekm 23-Mar-18 1:13
 Last Visit: 31-Dec-99 18:00     Last Update: 19-Jun-24 23:05 Refresh ᐊ Prev1...294295296297298299300301302303 Next ᐅ