Questions asked by dragonemperorhttps://discuss.codechef.com/questions/asked-by/14875/dragonemperor/?type=rssQuestions asked by <a href="/users/14875/dragonemperor" >dragonemperor</a>enThu, 26 Mar 2015 16:44:55 +0530TLE in c but AC in c++ in EQIDLIShttps://discuss.codechef.com/questions/38286/tle-in-c-but-ac-in-c-in-eqidlis<p>Here is my code which gives TLE in c but is accepted in c++. How can i make it run within time limit in c as it is my preferred language.</p>
<pre><code>#include<stdio.h>
int main()
{
int test,n,count;
scanf("%d",&test);
while(test--)
{
count=0;
int max=0,min=9999,maxi,mini;
scanf("%d",&n);
int arr[n],sum=0;
for(int i=0;i<n;i++)
{
scanf("%d",&arr[i]);
sum+=arr[i];
}
if(sum%n!=0)
{
printf("-1\n");
continue;
}
//printf("Min = %d Max = %d \n",min,max);
do
{
max=0,min=9999;
for(int i=0;i<n;i++)
{
if(arr[i]>=max)
{
max=arr[i];
maxi=i;
}
if(arr[i]<=min)
{
min=arr[i];
mini=i;
}
}
int temp=(max-min+1)/2;
//temp--;
arr[mini]+=temp;
arr[maxi]-=temp;
count++;
}while(max!=min);
printf("%d\n",count-1);
}
}
</code></pre>dragonemperorTue, 11 Feb 2014 20:30:30 +0530https://discuss.codechef.com/questions/38286/tle-in-c-but-ac-in-c-in-eqidliseqidliswhere to start solving graph theory problemhttps://discuss.codechef.com/questions/42956/where-to-start-solving-graph-theory-problem<p>Hello everyone. I need some suggestions on where to begin solving graph theory problems. I have read some books and articles and am able to program bfs, dfs, spanning tree problems etc. But when it comes to solving programming contest problems, I cannot solve any problem.</p>
<p>I mean in books, we have questions like "print nodes of a graph in bfs manner (graph in adjacency list or matrix)", but in programming contests,it is not the case.</p>
<p>I cannot even solve problems tagged easy. I was having similar problems in dp but now I can solve easy dp problems. But I am seriously lost in graph theory problems. Can anyone help me?</p>
<p>P.S. editorials tell logic of the problem but not how to solve them.Please give suggestions without any reference to editorials and wikipedia.</p>dragonemperorSat, 17 May 2014 11:09:12 +0530https://discuss.codechef.com/questions/42956/where-to-start-solving-graph-theory-problemgraphGetting WA in HDELIVERhttps://discuss.codechef.com/questions/43323/getting-wa-in-hdeliver<p>What is wrong with my implementation of HDELIVER?</p>
<p>Code : <a href="http://www.codechef.com/viewsolution/3934828"></a><a href="http://www.codechef.com/viewsolution/3934828">http://www.codechef.com/viewsolution/3934828</a></p>
<p>Initially I got TLE but after using better implementation, I am getting Wrong Answer.</p>dragonemperorFri, 23 May 2014 15:38:51 +0530https://discuss.codechef.com/questions/43323/getting-wa-in-hdelivergraphSegment tree programminghttps://discuss.codechef.com/questions/45370/segment-tree-programming<p>Hi guys, I need some help implementing segment tree algorithm (Implementing RMQ in segment tree).
I read the topcoder tutorial and tried implementing myself. But I made a mistake somewhere.
Here is the changes implemented in my code :</p>
<p>1) I used 0-indexing array as opposed to 1 indexing as used in topcoder.</p>
<p>2) Rather than storing index in tree, I am storing the value.</p>
<p>Problems:
1) The tree does not store the value perfectly, I mean there are error I am unable to find.</p>
<p>2) Every search query gives the minimum value in the entire tree rather than in an interval.</p>
<p>Here is my code:</p>
<pre><code>#include<stdio.h>
void create(int node,int arr[],int tree[],int i,int j,int n)
{
if(i==j)
tree[node]=arr[i];
else
{
create(node*2+1,arr,tree,i,(i+j)/2,n);
create(node*2+2,arr,tree,((i+j)/2)+1,j,n);
if(tree[node*2+1]<tree[node*2+2])
tree[node]=tree[node*2+1];
else
tree[node]=tree[node*2+2];
}
}
int search(int node,int arr[],int tree[],int i,int j,int n,int start,int end)
{
if(start<i&&end>j)
return -1;
if(start>=i&&end<=j)
return tree[node];
int p=search(node*2+1,arr,tree,i,(i+j)/2,n,start,end);
int q=search(node*2+2,arr,tree,((i+j)/2)+1,j,n,start,end);
if(p==-1)
return q;
else if(q==-1)
return p;
else
{
if(p<q)
return p;
else
return q;
}
}
int main()
{
int arr[6]={2,5,1,9,2,7};
int n=6,tree[16]={-1},temp;
create(0,arr,tree,0,5,6);
temp=n;
n=temp;
for(int i=0;i<16;i++)
{
printf("%d\t",tree[i]);
}
printf("\n%d\n",search(0,arr,tree,0,5,n,0,5));
printf("\n%d\n",search(0,arr,tree,0,5,n,0,4));
printf("\n%d\n",search(0,arr,tree,0,5,n,0,3));
printf("\n%d\n",search(0,arr,tree,0,5,n,0,2));
printf("\n%d\n",search(0,arr,tree,0,5,n,0,1));
printf("\n%d\n",search(0,arr,tree,0,5,n,0,0));
printf("\n%d\n",search(0,arr,tree,0,5,n,1,5));
printf("\n%d\n",search(0,arr,tree,0,5,n,2,5));
printf("\n%d\n",search(0,arr,tree,0,5,n,3,5));
printf("\n%d\n",search(0,arr,tree,0,5,n,4,5));
printf("\n%d\n",search(0,arr,tree,0,5,n,5,5));
printf("\n%d\n",search(0,arr,tree,0,5,n,2,3));
printf("\n%d\n",search(0,arr,tree,0,5,n,2,4));
printf("\n%d\n",search(0,arr,tree,0,5,n,1,4));
printf("\n%d\n",search(0,arr,tree,0,5,n,1,2));
printf("\n%d\n",search(0,arr,tree,0,5,n,1,3));
}
</code></pre>dragonemperorFri, 20 Jun 2014 12:46:23 +0530https://discuss.codechef.com/questions/45370/segment-tree-programmingsegment-treermqnot answered questionshttps://discuss.codechef.com/questions/47592/not-answered-questions<p>I see most of the questions in peer section have 0 solutions or 1 solutions. Are these questions extremely hard or wrong or people just don't try to solve them? Where are the editorials in those questions?</p>dragonemperorTue, 15 Jul 2014 16:50:18 +0530https://discuss.codechef.com/questions/47592/not-answered-questionspeerPRIME1 solutionhttps://discuss.codechef.com/questions/47681/prime1-solution<p>Hello guys, I am stuck in a medium level problem PRIME1. I used sieve to generate primes upto 32000 (My first sieve implementation, so if it is wrong, please point out.) and used those primes to generate all others, but I am getting TLE. I have looked previous posts and answers in the editorial but was not able to solve it. Please help.</p>
<p>Here is the id of the solution : 4335757</p>
<p>I am also posting it here : </p>
<h1>include<stdio.h></h1>
<h1>define MAX_PRIME 32000</h1>
<p>int primes[MAX_PRIME],req_prime[MAX_PRIME];</p>
<p>int total_prime=0;</p>
<p>/<em>Initialise the array to 1</em>/</p>
<p>void set_to_one()</p>
<p>{</p>
<pre><code>for(int i=0;i<MAX_PRIME;i++)
primes[i]=1;
</code></pre>
<p>}</p>
<p>/<em>Finds primes upto 32000 and puts them in another array req_prime</em>/</p>
<p>void preprocess()</p>
<p>{</p>
<pre><code>primes[0]=primes[1]=0;
for(int i=2;i<MAX_PRIME;i++)
{
if(primes[i])
{
req_prime[total_prime++]=i;
for(int j=i+i;j<MAX_PRIME;j+=i)
{
primes[j]=0;
}
}
}
</code></pre>
<p>}</p>
<p>/<em>Just to check if all primes are identified or not. They are for debugging only.</em>/</p>
<p>void print_all_primes()</p>
<p>{</p>
<pre><code>for(int i=0;i<MAX_PRIME;i++)
printf("%d\t",primes[i]);
</code></pre>
<p>}</p>
<p>/<em>To check if the number is a prime or not</em>/</p>
<p>void check_prime(int n)</p>
<p>{</p>
<pre><code>int count=0;
for(int i=0;i<total_prime;i++)
{
if(n%req_prime[i]==0 && n!=req_prime[i])
count++;
if(req_prime[i]>=n)
break;
}
if(count==0 && n!=1)
printf("%d\n",n);
</code></pre>
<p>}</p>
<p>/<em> Checks all numbers in the array </em>/</p>
<p>void solve_problem(int arr[],int size)</p>
<p>{</p>
<pre><code>for(int i=0;i<size;i++)
{
check_prime(arr[i]);
}
</code></pre>
<p>}</p>
<p>int main()</p>
<p>{</p>
<pre><code>int test,a,b;
scanf("%d",&test);
set_to_one();
preprocess();
//print_all_primes();
while(test--)
{
scanf("%d%d",&a,&b);
int arr[b-a+1];
for(int i=a;i<=b;i++)
arr[i-a]=i;
solve_problem(arr,b-a+1);
}
return 0;
</code></pre>
<p>}</p>dragonemperorWed, 16 Jul 2014 15:35:45 +0530https://discuss.codechef.com/questions/47681/prime1-solutionprime1understanding segment treehttps://discuss.codechef.com/questions/49782/understanding-segment-tree<p>Hello guys, I need a little help implementing and understanding segment tree data structure. I have read many online tutorials and I understand the concept pretty well. But when comes to implementing the code, my knowledge falls out of the sky. I am not getting desired output in any of my attempts. What should I do next? </p>dragonemperorSun, 17 Aug 2014 10:56:04 +0530https://discuss.codechef.com/questions/49782/understanding-segment-treesegment-treeOutput of the program and whyhttps://discuss.codechef.com/questions/50328/output-of-the-program-and-why<p>#include <stdio.h></p>
<p>#if X == 3</p>
<p>#define Y 3</p>
<p>#else</p>
<p>#define Y 5
#endif</p>
<p>int main()</p>
<p>{</p>
<p>printf("%d", Y);</p>
<p>return 0;</p>
<p>}</p>dragonemperorThu, 28 Aug 2014 11:25:42 +0530https://discuss.codechef.com/questions/50328/output-of-the-program-and-whyanswerSolutions to ICPC problemshttps://discuss.codechef.com/questions/50900/solutions-to-icpc-problems<p>Can anyone give me a link to where I can find solutions/Editorials for ICPC-regionals and world finals? Google search says it is available in baylor site. But I can find the questions not editorials. </p>dragonemperorSat, 13 Sep 2014 19:07:07 +0530https://discuss.codechef.com/questions/50900/solutions-to-icpc-problemsacm-icpcModular arithmetic helphttps://discuss.codechef.com/questions/54847/modular-arithmetic-help<p>Can somebody tell me how to use modular arithmetic in C programming? Every time I make some mistakes and am unable to find the error. My approach seems right but modular arithmetic part isn't. </p>
<p>I have tried some programs and got success in very few (two or three only). Also they had only addition and subtraction problem. When it comes to division, I am out of knowledge.</p>
<p>The last problem I tried was <a href="https://www.hackerrank.com/challenges/game-of-throne-ii"> this</a> and my approach is same as that in editorial. But I am getting wrong answer in all test cases except the sample ones. Can you please check my code and rectify my error?</p>
<p><a href="http://ideone.com/PnStBF"> My code </a> </p>dragonemperorWed, 05 Nov 2014 17:00:26 +0530https://discuss.codechef.com/questions/54847/modular-arithmetic-helpmodularPreparing for ICPChttps://discuss.codechef.com/questions/54848/preparing-for-icpc<p>Can anybody tell me how to prepare for ICPC? My team got selected for onsite rounds(Amritapuri and Gwalior) by solving one and two problems respectively. I know I have only one month left and I can't go to top positions but I want my team to solve three-four problems in amritapuri and at least three in Gwalior round. Is it possible? How should I prepare?</p>
<p>I have solved more than 100 problems in codechef but all were easy adhoc and simple math problems. I solved some algorithmic problems (like graph traversing, fenwick tree, some string problems(edit distance,LCS),sieve etc) but all in practice session (never in real contest time). </p>
<p>Can anyone give me some tips?</p>dragonemperorWed, 05 Nov 2014 17:11:03 +0530https://discuss.codechef.com/questions/54848/preparing-for-icpcicpc_prepModifying the problemhttps://discuss.codechef.com/questions/55328/modifying-the-problem<p>I was trying to solve <a href="http://www.codechef.com/ACMAMR12/problems/LIGHTS">http://www.codechef.com/ACMAMR12/problems/LIGHTS</a> yesterday. Accidentally, I read the question wrong. Instead of doing flips on rows only, I did it for for row and column. Obviously my approach was wrong and after looking at others solutions, I found my mistake. Now I wonder, what if the question had said what I previously thought. What if flips are allowed not only in rows but also in columns. </p>
<p>e.g. k=2<br>
<em> . * </em><br>
. * . .<br>
<em> . * </em><br></p>
<p>flipping row 2 and column 2, we will get maximum *. </p>
<p>I am unable to find an approach for this. I think it will be a dp problem. Still, how to solve it? Any pointers would be helpful.</p>dragonemperorThu, 13 Nov 2014 20:52:48 +0530https://discuss.codechef.com/questions/55328/modifying-the-problemlightssegmented_sievehttps://discuss.codechef.com/questions/60536/segmented_sieve<p>Hi, I have used sieve of eratosthenes a number of times, but am new to segmented version of it. I came to know about it while solving PRIME1. But I am stuck here. I first found primes up to some point (upto 100(say MAX) while testing, I will set it for 10^5). When the range of numbers is greater than MAX, the output is fine. But for less than it, I am not getting primes upto sqrt(Max_Number_in_range). I can't understand how to modify the code. Please help.</p>
<p>P.S. Can you also tell me whether the approach is fast enough or I need some other modifications??</p>
<p>code : <a href="http://ideone.com/KdltlA">http://ideone.com/KdltlA</a> </p>dragonemperorFri, 02 Jan 2015 14:00:43 +0530https://discuss.codechef.com/questions/60536/segmented_sieveprime1chefhack wrong answerhttps://discuss.codechef.com/questions/60781/chefhack-wrong-answer<p>Can anybody tell me what is wrong with my solution??</p>
<p><a href="http://ideone.com/xYVgC2"> My code </a><br>
<a href="http://www.codechef.com/JAN13/problems/CHEFHACK">Question</a></p>
<p>In editorial there are some corner test cases, and I am not able to pass them. I know for which test cases it is wrong, but not the reason why I am getting the wrong answer. Any pointers would be helpful. Thanks in advance.</p>dragonemperorMon, 05 Jan 2015 12:25:03 +0530https://discuss.codechef.com/questions/60781/chefhack-wrong-answerchefhackCan't understand solutionhttps://discuss.codechef.com/questions/62813/cant-understand-solution<p>Can any body help me understand the solution of <a href="http://www.codechef.com/RCSN2015/problems/RECBOX"> this </a>. I saw the approaches taken by other contestants but I am unable to understand why such simple approach worked. </p>dragonemperorMon, 26 Jan 2015 00:41:48 +0530https://discuss.codechef.com/questions/62813/cant-understand-solutionrecboxuse of coding contesthttps://discuss.codechef.com/questions/63052/use-of-coding-contest<p>Are knowledge gained though programming contests gonna help in career at companies like infosys, wipro, TCS, Accenture or is it going to be wasted??</p>
<p>p.s. Not every one is going to big companies like microsoft, facebook, or Google. Please answer keeping this in mind.</p>dragonemperorTue, 27 Jan 2015 19:26:44 +0530https://discuss.codechef.com/questions/63052/use-of-coding-contestdont_knowHow to solvehttps://discuss.codechef.com/questions/63196/how-to-solve<p>Can any one give some pointers on how to solve these two problems??</p>
<p><a href="http://www.codechef.com/ALMA2015/problems/ALMA05">http://www.codechef.com/ALMA2015/problems/ALMA05</a></p>
<p><a href="http://www.codechef.com/ALMA2015/problems/ALMA04">http://www.codechef.com/ALMA2015/problems/ALMA04</a></p>
<p>I was able to solve the rest three during contest but was out of luck (or knowledge) for these two.</p>dragonemperorThu, 29 Jan 2015 12:33:56 +0530https://discuss.codechef.com/questions/63196/how-to-solvealmaWhy am I getting TLE and WAhttps://discuss.codechef.com/questions/63336/why-am-i-getting-tle-and-wa<p>I am getting TLE for <a href="http://www.codechef.com/DCOD2015/problems/CD1IT5"> this </a>. The approach is union find algorithm and everyone else's similar approach got AC.
<br>
<a href="http://www.codechef.com/viewsolution/6043531"> My Code </a></p>
<p>Also, for <a href="http://www.codechef.com/DCOD2015/problems/CD1IT4"> this </a>, I am getting WA. It works for all my test cases but I am not able to find the problem.</p>
<p><a href="http://ideone.com/of3UxD"> My code 1 </a><br>
<a href="http://www.codechef.com/viewsolution/6042758"> My code 2</a></p>dragonemperorFri, 30 Jan 2015 14:55:00 +0530https://discuss.codechef.com/questions/63336/why-am-i-getting-tle-and-wacode.itWA in STFMhttps://discuss.codechef.com/questions/64801/wa-in-stfm<p>In the problem STFM of FEB long challenge, my approach got AC for two sub tasks. It failed when value of x increased. After looking at the editorial, I tried it again with my approach with the mod trick(that factorial becomes zero). Now it is giving WA for all subtasks. I am unable to find my mistake. Can any one help please?</p>
<p><a href="http://ideone.com/fWnj7z"> Second approach with WA for all sub task </a></p>
<p><a href="http://www.codechef.com/viewsolution/6305443"> First answer with AC for two sub task</a></p>dragonemperorTue, 17 Feb 2015 20:58:02 +0530https://discuss.codechef.com/questions/64801/wa-in-stfmwaSIGSEGV why?https://discuss.codechef.com/questions/65128/sigsegv-why<p>Why am I getting SIGSEGV in <a href="http://www.codechef.com/CDMU2015/problems/CDMU02"> this problem </a>?</p>
<p><a href="http://www.codechef.com/viewsolution/6326898"> My solution </a></p>dragonemperorSun, 22 Feb 2015 12:53:48 +0530https://discuss.codechef.com/questions/65128/sigsegv-whysigsegvApproach of the problemhttps://discuss.codechef.com/questions/65129/approach-of-the-problem<p>Can anyone tell me how to approach <a href="http://www.codechef.com/CDMU2015/problems/CDMU04">this</a> problem?</p>
<p>Every successful submissions have used a similar approach and I am unable to understand it. </p>dragonemperorSun, 22 Feb 2015 12:56:45 +0530https://discuss.codechef.com/questions/65129/approach-of-the-problemmobius_functionNeed help in these two problemshttps://discuss.codechef.com/questions/65179/need-help-in-these-two-problems<p>Can anybody help me with these two problems?</p>
<p>In the first problem, I am getting TLE for last sub task only. AC for rest,</p>
<p><a href="http://www.codechef.com/LTIME01/problems/NUMFACT">Problem</a><br>
<a href="http://www.codechef.com/viewsolution/6335312">My solution</a></p>
<p>In the second one, I am getting WA for first subtask. AC for rest.</p>
<p><a href="http://www.codechef.com/LTIME01/problems/COUPON">Problem</a><br>
<a href="http://www.codechef.com/viewsolution/6335534">My solution</a></p>dragonemperorSun, 22 Feb 2015 16:48:16 +0530https://discuss.codechef.com/questions/65179/need-help-in-these-two-problemssieve_and_dpWA in alma04https://discuss.codechef.com/questions/65296/wa-in-alma04<p>Can anybody tell me why I am getting WA in <a href="http://www.codechef.com/viewsolution/6345416"> this </a> ? </p>
<p>This is my first recurrence relation problem using matrix exponentiation method.
The power to which the matrix will be raised is n-1,n-2 or n-4 and why?</p>
<p><a href="http://www.codechef.com/ALMA2015/problems/ALMA04"> Problem </a></p>dragonemperorTue, 24 Feb 2015 18:52:06 +0530https://discuss.codechef.com/questions/65296/wa-in-alma04matrix_expoDifference in the approachhttps://discuss.codechef.com/questions/65323/difference-in-the-approach<p>I tried solving <a href="http://www.codechef.com/DCOD2015/problems/CD1IT5"> this </a> using union find algorithm.</p>
<p>I got TLE in one and AC in second approach. I made only one line difference between the two and both are giving correct answer on my laptop. Can anyone tell me why this happened?</p>
<p><a href="http://www.codechef.com/viewsolution/6348113"> TLE </a></p>
<p><a href="http://www.codechef.com/viewsolution/6348118"> AC </a></p>dragonemperorWed, 25 Feb 2015 18:20:30 +0530https://discuss.codechef.com/questions/65323/difference-in-the-approachtleWhy am I getting SIGSEGVhttps://discuss.codechef.com/questions/65352/why-am-i-getting-sigsegv<p>My code for <a href="http://www.codechef.com/problems/FGFS"> this </a> is giving sigsegv error. Many solutions with similar approach got AC. </p>
<p>I also tried to solve it using structure, but couldn't sort it. sort() of STL didn't work for it. I don't know why.</p>
<p><a href="http://www.codechef.com/viewsolution/6353249"> My code </a></p>
<p><a href="http://ideone.com/RfujQo"> Tried using structure </a>. If I remove sort(), then of course the answer is wrong, but I am getting wrong answer, not RE.</p>dragonemperorThu, 26 Feb 2015 20:04:07 +0530https://discuss.codechef.com/questions/65352/why-am-i-getting-sigsegvsigsegvBeat by bithttps://discuss.codechef.com/questions/65500/beat-by-bit<p>I tried these two problems in yesterday's contest Bit by Bit. First one gave WA and second one TLE. The TLE problem is my first shortest path program. Is there any way to optimize it or is there another approach for the problem? Also, why am I getting WA in first one where approach is same as the ones used by other contestants?</p>
<p><a href="http://www.codechef.com/BBYB2015/problems/BIT1501"> Problem </a> and
<a href="http://ideone.com/Pkh6RA"> WA solution </a>
<br>
<a href="http://www.codechef.com/BBYB2015/problems/BIT1505"> Problem </a> and <a href="http://ideone.com/JKPyIE"> Solution TLE </a>
<br></p>dragonemperorMon, 02 Mar 2015 18:38:14 +0530https://discuss.codechef.com/questions/65500/beat-by-bittleApproach for these problemshttps://discuss.codechef.com/questions/66257/approach-for-these-problems<p>Can anyone tell me how to solve these two problems?<br>
<a href="http://www.codechef.com/CDGO2015/problems/RTREE"> problem 1 </a> <br>
and <br><a href="http://www.codechef.com/CDGO2015/problems/AMAGIC"> problem 2 </a></p>
<p>I saw the solutions of others but am unable to understand the approach.</p>dragonemperorWed, 18 Mar 2015 14:58:25 +0530https://discuss.codechef.com/questions/66257/approach-for-these-problemscodigo2015can't understandhttps://discuss.codechef.com/questions/66258/cant-understand<p>Can anyone help me understand how to find nth catalan number mod a prime number? I found <a href="http://stackoverflow.com/questions/11873334/what-is-the-fastest-known-algorithm-to-find-the-n-th-catalan-number-mod-m">this </a> but am not able to understand it. (the last solution posted by Ben Voigt)
I am lost at the line </p>
<p><i>Use the Sieve of Eratosthenes to find and store pairs of factors for all composite number </i>
sieve</p>
<p>What does it mean and how to find it? I couldn't make out this part in the code provided there</p>
<p>P.S. I understand the approach. Just not the implementations. </p>
<p>Thanks </p>dragonemperorWed, 18 Mar 2015 15:04:34 +0530https://discuss.codechef.com/questions/66258/cant-understandsievemodular arithmetichttps://discuss.codechef.com/questions/66290/modular-arithmetic<p>is (a/b)%m equal to {(a%m)/(b%m)}%m ? (i.e. before doing modular inverse, find mod of both numerator and denominator)</p>
<p>I knew (a/b)%m is {a%m * (b^(m-2))%m}%m</p>
<p>But in this <a href="http://www.codechef.com/viewsolution/6538280"> program </a> for finding nth catalan number, the author found (2n)! mod m , n! mod m and (n+1)! mod m and then used the modular inverse to find the result. </p>
<p>Is the approach wrong but got AC because of bad test case or the approach is correct? If it is correct, can anyone point out why?</p>dragonemperorWed, 18 Mar 2015 20:18:25 +0530https://discuss.codechef.com/questions/66290/modular-arithmeticmoduloIs there any error?https://discuss.codechef.com/questions/66947/is-there-any-error<p>Can any one point out if I made any error in the following code? This is the preprocessing step in KMP algorithm and is giving correct answer for my test cases. I just want to know whether the line, I have used a comment against, is correct or not.</p>
<p><a href="http://ideone.com/1xvkhN"> My code </a></p>dragonemperorThu, 26 Mar 2015 16:44:55 +0530https://discuss.codechef.com/questions/66947/is-there-any-errorkmp