Questions asked by karangreat234https://discuss.codechef.com/questions/asked-by/294213/karangreat234/?type=rssQuestions asked by <a href="/users/294213/karangreat234" >karangreat234</a>enSat, 09 Feb 2019 18:53:51 +0530Same code giving AC and WAhttps://discuss.codechef.com/questions/139853/same-code-giving-ac-and-wa<p>This is the first question of November-2016-long challenge.
Question link:-
<a href="https://www.codechef.com/problems/ALEXTASK">https://www.codechef.com/problems/ALEXTASK</a></p>
<p>Link to my code which gives 30 points:- <a href="https://www.codechef.com/viewsolution/21550890">https://www.codechef.com/viewsolution/21550890</a></p>
<p>Link to my code which gives 100 points: - <a href="https://www.codechef.com/viewsolution/21550940">https://www.codechef.com/viewsolution/21550940</a></p>
<p>In the first code, I wrote this to calculate lcm : </p>
<p>long long int lcm(long long int a,long long int b)
{</p>
<pre><code>long long int z = (a*b)/gcd(a,b);
return z;
</code></pre>
<p>}</p>
<p>In the second code, I wrote this to calculate LCM :</p>
<p>long long int lcm(long long int a,long long int b)
{</p>
<pre><code> return (a*b)/gcd(a,b);
</code></pre>
<p>}</p>
<p>why the Second one got AC and first one got WA for the last subtask?
Can anybody please explain?
<a href="/users/187411/vijju123">@vijju</a>
<a href="/users/1/admin">@admin</a></p>karangreat234Fri, 09 Nov 2018 12:16:12 +0530https://discuss.codechef.com/questions/139853/same-code-giving-ac-and-waarraylcmWhy is thIS CORRECT solution getting WA for GMEDIAN?https://discuss.codechef.com/questions/140230/why-is-this-correct-solution-getting-wa-for-gmedian<p>This is my solution which only got 5 points,I did everything right, then why I did not get 30 points? I used the Fermat Modulo Theorem to calculate (n C r) % p :- <a href="https://www.codechef.com/viewsolution/21540233">https://www.codechef.com/viewsolution/21540233</a></p>karangreat234Tue, 13 Nov 2018 18:13:12 +0530https://discuss.codechef.com/questions/140230/why-is-this-correct-solution-getting-wa-for-gmediancombinatoricsnovembergmedianlongBest Editorials for the problems of Codechef and Codeforces!(beginners and intermediates)https://discuss.codechef.com/questions/141333/best-editorials-for-the-problems-of-codechef-and-codeforcesbeginners-and-intermediates<p>I and my TEAM have taken an initiative to write editorials which are pretty easy to understand even for beginners.I write them in the easiest manner possible and explain the solution from scratch so that even a beginner can understand thoroughly!</p>
<p>I even provide extra links at the end of my editorial(s)/solution(s) to learn the concept(S) involved.</p>
<p>And I even try to explain things clearly in detail with images!
Feedback will be welcomed!:) :D</p>
<p>I write editorials in my Quora Blog:-</p>
<p>1)
<a href="https://www.quora.com/profile/Karan-Gujar-32/Codeforces-Solutions/Codeforces-Educational-Round-55-solution-to-problem-No-1-Vasya-and-Book">https://www.quora.com/profile/Karan-Gujar-32/Codeforces-Solutions/Codeforces-Educational-Round-55-solution-to-problem-No-1-Vasya-and-Book</a></p>
<p>2)
<a href="https://www.quora.com/profile/Karan-Gujar-32/Codechef-Long-Challenge-Solutions/Solution-to-Long-Challenge-Nov-2k18-1st-Codechef-Problem">https://www.quora.com/profile/Karan-Gujar-32/Codechef-Long-Challenge-Solutions/Solution-to-Long-Challenge-Nov-2k18-1st-Codechef-Problem</a></p>karangreat234Fri, 30 Nov 2018 16:32:31 +0530https://discuss.codechef.com/questions/141333/best-editorials-for-the-problems-of-codechef-and-codeforcesbeginners-and-intermediatescodeforceseditorialcodechefBest Editorials for the problems of Hackerearth!!(intermediates+beginners)https://discuss.codechef.com/questions/141569/best-editorials-for-the-problems-of-hackerearthintermediatesbeginners<p>I and my TEAM have taken an initiative to write editorials which are pretty easy to understand even for beginners.I write them in the easiest manner possible and explain the solution from scratch so that even a beginner can understand thoroughly!</p>
<p>I even provide extra links at the end of my editorial(s)/solution(s) to learn the concept(S) involved.</p>
<p>And I even try to explain things clearly in detail with images! Feedback will be welcomed!:) :D</p>
<p>I write editorials in my Quora Blog:-</p>
<p><a href="https://hackerearht.quora.com/Hackerearth-Hourstrom-3-Problem-a">https://hackerearht.quora.com/Hackerearth-Hourstrom-3-Problem-a</a></p>
<p>Feedback is welcomed.
<strong>H</strong>appy Coding ;)</p>karangreat234Tue, 04 Dec 2018 23:44:57 +0530https://discuss.codechef.com/questions/141569/best-editorials-for-the-problems-of-hackerearthintermediatesbeginnersintermediateseditorialshackerearthcodingsolutionseasyHow to start with competitive programming ? (for beginners)https://discuss.codechef.com/questions/141579/how-to-start-with-competitive-programming-for-beginners<p>Read:
<a href="https://www.quora.com/How-do-I-start-with-programming-and-then-with-competitive-programming/answer/Karan-Gujar-32">https://www.quora.com/How-do-I-start-with-programming-and-then-with-competitive-programming/answer/Karan-Gujar-32</a></p>karangreat234Wed, 05 Dec 2018 11:17:03 +0530https://discuss.codechef.com/questions/141579/how-to-start-with-competitive-programming-for-beginnersbeginnerscodingprogrammingstartingcompetitiveCheating case caught for INTXOR problemhttps://discuss.codechef.com/questions/142431/cheating-case-caught-for-intxor-problem<p>This person has shared the solution of INTXOR problem before the contest ended through a video.
He uploaded the video on 17th December,whereas the contest ended on 18th-December-1:00-AM.
Link: <a href="https://youtu.be/yoJZj8OuFfk">https://youtu.be/yoJZj8OuFfk</a>
Please look into the matter <a href="/users/187411/vijju123">@vijju</a> <a href="/users/1/admin">@admin</a>.
And all the wannabe Editorialist(s),its my humble request, please don't post solutions to problems before the contest ends!
:) </p>karangreat234Wed, 19 Dec 2018 18:49:56 +0530https://discuss.codechef.com/questions/142431/cheating-case-caught-for-intxor-problemintxorsagacheatingDeleted Question on COdechefhttps://discuss.codechef.com/questions/142647/deleted-question-on-codechef<p>I want to delete this question.</p>karangreat234Sun, 23 Dec 2018 12:52:34 +0530https://discuss.codechef.com/questions/142647/deleted-question-on-codechefsubstringprogrammingstringcompetitiveGood Problem(s) on 'AND' operation?!?!https://discuss.codechef.com/questions/142806/good-problems-on-and-operation<p>I am searching for good problems which involves the 'and' operation specifically,sometimes with bit manipulation tricks and sometimes with bit-masking techniques + segment trees!</p>
<p>I was only able to find 2-3 problems like these, can you suggest some more ? :)
I would love all the suggestions!!</p>karangreat234Mon, 24 Dec 2018 23:23:00 +0530https://discuss.codechef.com/questions/142806/good-problems-on-and-operationandoperatncompetitiveprogramminglearningbitwiseWhat is the meaning of pairwise distinct integers?https://discuss.codechef.com/questions/143249/what-is-the-meaning-of-pairwise-distinct-integers<p>I am a newbie on Codechef.
Any help will be appreciated :)
If it is given in the problem statement that :
"All elements of the given array are pairwise distinct, does it mean that all the elements of the array are distinct ?"
Thanks in advance! :)</p>karangreat234Fri, 04 Jan 2019 20:02:12 +0530https://discuss.codechef.com/questions/143249/what-is-the-meaning-of-pairwise-distinct-integersnewbiebeginnerchallengequestionlongjan2019Div.1 vs Div.2https://discuss.codechef.com/questions/143324/div1-vs-div2<p><em>Are all the questions which are included for division-'2' but not for division-'1' strictly easier than questions of DIV-1 ?</em></p>
<p><em>And similarly,are all the questions which are included in division-1 but not in division-2 are strictly harder than questions of DIV.-2 ?</em></p>
<p>Thanks!:)</p>karangreat234Sun, 06 Jan 2019 12:39:20 +0530https://discuss.codechef.com/questions/143324/div1-vs-div2comparisonprogrammingknowledgediv1div2DOUBT REGARDING PIZZA SLICE PROBLEM OF LONG CHALLENGEhttps://discuss.codechef.com/questions/143586/doubt-regarding-pizza-slice-problem-of-long-challenge<p>I don't know why my last question was deleted by Codechef which was the same as this. The problem statement is not very clear, so I am asking it here, please don't delete the question before I get my query solved.</p>
<p><strong><em>Problem Link :</em></strong></p>
<p><a href="https://www.codechef.com/JAN19B/problems/XYPIZQ">https://www.codechef.com/JAN19B/problems/XYPIZQ</a></p>
<p>It is mentioned in the problem that : Mark N points A1,A2,A3,…,AN on one ray in this order (A1 is closest to A0).</p>
<p>So does that mean, first comes A0,then A1,then A2 and so on... or I can randomly mark A1,A2,A3,A4,..ETC....wherever I want ?</p>
<p>Please clear my doubt guys!! _/_ :(</p>karangreat234Fri, 11 Jan 2019 18:34:15 +0530https://discuss.codechef.com/questions/143586/doubt-regarding-pizza-slice-problem-of-long-challengehelpchallengepleaselongjandoubtCan anybody explain the solution to this interesting string-problem based on optimization ?https://discuss.codechef.com/questions/144028/can-anybody-explain-the-solution-to-this-interesting-string-problem-based-on-optimization<p>This is a problem from previous contest : <a href="https://www.hackerearth.com/practice/algorithms/searching/binary-search/practice-problems/algorithm/superior-substring-dec-circuits-e51b3c27/">https://www.hackerearth.com/practice/algorithms/searching/binary-search/practice-problems/algorithm/superior-substring-dec-circuits-e51b3c27/</a></p>
<p>Problem-Statement :---></p>
<p>You are given a string of length .
If a string contains at least one character whose frequency is greater than or equal to the half of the length of the string, then the string is called superior.</p>
<p>You are required to find the length of the longest superior substring available in the given string .</p>
<p>Note: Here half is considered under integer division i.e. , etc.</p>
<p>Input format</p>
<p>First line: Integer 't' that represents the total number of test cases</p>
<p>For each test case:</p>
<p>First line: Integer 'n' that represents the length of the string </p>
<p>Next line: String 'S' of the length 'N'</p>
<p>Output format :</p>
<p>For each test case, print the length of the longest superior substring in a new line.</p>
<p>Constraints :
1<=T<=10</p>
<p>1<=N<=10^5</p>
<p>The string contains only lowercase English alphabets.</p>karangreat234Wed, 16 Jan 2019 11:32:50 +0530https://discuss.codechef.com/questions/144028/can-anybody-explain-the-solution-to-this-interesting-string-problem-based-on-optimizationbinarysearchoptimizationstringIs there any formula to calculate nth fibonacci number ?https://discuss.codechef.com/questions/144136/is-there-any-formula-to-calculate-nth-fibonacci-number<p>Suppose we are given, a(0)=x ; a(1)=y </p>
<p>and the relation, a[i]=a[i-1]+a[i-2] </p>
<p>and , we are asked to calculate a(n) , how to calculate it if n is as big as 10^9 ?</p>
<p>Thanks ! :-) </p>karangreat234Fri, 18 Jan 2019 09:18:39 +0530https://discuss.codechef.com/questions/144136/is-there-any-formula-to-calculate-nth-fibonacci-numberfibonnacidynamicsequenceDoubt related to a Dynamic Programming problem!https://discuss.codechef.com/questions/144228/doubt-related-to-a-dynamic-programming-problem<p>I sincerely hope, that this question does not belong to any ongoing contest : D
<a href="/users/263381/aryanc403">@aryanc403</a></p>
<p>If it does, please don't answer this question :)</p>
<p>We are given integers,namely, a,b,c and d. Also, 0<=a,b,c,d<=1000</p>
<p>We have to satisfy this equation : a+b^2+c^3+d^4<=S,</p>
<p>where , 0<=s<=10^18</p>
<p>We will be given an integer, 'S' as the input.</p>
<p>We have to find the no. of integral solutions which satisfy the above equation!:)</p>
<p>I know the brute-force way, can anybody propose a nice dp-way to solve it? Thanks.</p>
<p>Link to the sequence :----> <a href="https://oeis.org/search?q=1%2c4%2c7%2c8%2c9%2c11%2c12%2c12&fmt=data">https://oeis.org/search?q=1%2c4%2c7%2c8%2c9%2c11%2c12%2c12&fmt=data</a></p>karangreat234Sun, 20 Jan 2019 23:59:09 +0530https://discuss.codechef.com/questions/144228/doubt-related-to-a-dynamic-programming-problemno.ofintegralsolutionsprogrammingdynamicCan we find the length of the longest subarray with sum>k efficiently?https://discuss.codechef.com/questions/144384/can-we-find-the-length-of-the-longest-subarray-with-sumk-efficiently<p>Here, 'k' can be any integer.</p>
<p>My O(nlogn) solution is as follows :- <a href="https://ideone.com/Ff3CcO">https://ideone.com/Ff3CcO</a></p>
<p>Is there any O(n) algorithm for above?</p>
<p>Thanks.</p>
<p>Note:-
1)I've done my research.
2)No, this problem does not belong to any ongoing contest in the world :-)</p>karangreat234Wed, 23 Jan 2019 12:55:27 +0530https://discuss.codechef.com/questions/144384/can-we-find-the-length-of-the-longest-subarray-with-sumk-efficientlysubarraysumefficiencyHow to find the count of the number of subarrays whose max=k ?https://discuss.codechef.com/questions/144755/how-to-find-the-count-of-the-number-of-subarrays-whose-maxk<p>I do have a nice solution which works in O(N),I want to know the ideas of other people on it?
Thanks!:)</p>karangreat234Fri, 01 Feb 2019 13:41:16 +0530https://discuss.codechef.com/questions/144755/how-to-find-the-count-of-the-number-of-subarrays-whose-maxksubarraysmaximumWrong updation of score for Feb-long challenge problem.https://discuss.codechef.com/questions/145162/wrong-updation-of-score-for-feb-long-challenge-problem<p>My score in the challenge problem is:- 10356.56 points.
My rank was 42 at 4:15 pm,after 5 minutes it turned back to 197,after few minutes it again went back to 42, then again back to 197, now its 42 again.</p>
<p>Why is this happening, can Codechef fix this please?</p>karangreat234Sat, 09 Feb 2019 18:53:51 +0530https://discuss.codechef.com/questions/145162/wrong-updation-of-score-for-feb-long-challenge-problem2016feblong