Re: [algogeeks] spoj problem chairs

2011-06-19 Thread abc abc
@above Better you ask it on spoj forum On Sun, Jun 19, 2011 at 7:27 PM, saurabh singh saurab...@gmail.com wrote: I am getting WA for this problem.I dont know whether its case of overflow or I have come up with a wrong formula, https://www.spoj.pl/problems/CHAIR/ I am coding in python so I

[algogeeks] spoj NKTM

2011-06-14 Thread kartik sachan
https://www.spoj.pl/problems/NTKM/ my code is : # includeiostream # includecstdio # includealgorithm using namespace std; int main() { long long int n; while(1) { long long int a[1]={0},i; if(scanf(%lld,n)==EOF) break; for(i=0;in;i++) scanf(%lld,a[i]);

[algogeeks] SPOJ THRBL

2011-06-10 Thread kartik sachan
http://www.spoj.pl/problems/THRBL/ my code is i am getting TLE # includeiostream # includecstdio using namespace std; //int search(long long int [],long long ) int main() { while(1) { int n,m; int count=0; long long int a[50010]={0}; int b[50010],c[50010]; if((scanf(%d%d,n,m))==EOF) break; int

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread abhishek iyer
@Karthik : Can you please the logic ??. Would be nice .. On Fri, Jun 10, 2011 at 12:42 PM, kartik sachan kartik.sac...@gmail.comwrote: http://www.spoj.pl/problems/THRBL/ my code is i am getting TLE # includeiostream # includecstdio using namespace std; //int search(long long int [],long

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread kartik sachan
what i understand from the problem was that. n no of higests are given and a and b and city no i.e from city a a ball is thrown to city no b so i have done from array a[] i.e hieght { n...no of times} find all the element between b[i].city A and

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread nicks
i agree with the logici also implemented it...and getting TLE...there must exist some better method :( On Fri, Jun 10, 2011 at 2:18 AM, kartik sachan kartik.sac...@gmail.comwrote: what i understand from the problem was that. n no of higests are given and a and b and city no

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread kartik sachan
how should we get TLE loop total running less than 10^6?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread saurabh singh
Use Range Maximum Query. On Fri, Jun 10, 2011 at 4:15 PM, kartik sachan kartik.sac...@gmail.comwrote: how should we get TLE loop total running less than 10^6?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread keyan karthi
u construct a tree nlogn , every node answers a query.. (or u get ans with a recursion) in log(n) , so when u r doing a lot of query RMQ proves to be very fast On Fri, Jun 10, 2011 at 6:28 PM, nicks crazy.logic.k...@gmail.com wrote: ya i saw that in the comments on spoj someone suggested to use

Re: [algogeeks] SPOJ THRBL

2011-06-10 Thread saurabh singh
Suppose you are given an array a[]={2,3,1,4,6,7,10} now for successfully transferring the ball,from ith city to jth city,a[i] max(a[i..j-1]). A naive approach would be to calculate all possible max[i][j] that is max for each interval and then answer the query in 0(1) time.Another approach would

[algogeeks] SPOJ IMPORT

2011-06-09 Thread kartik sachan
http://www.spoj.pl/problems/IMPORT/ my code is # includestdio.h float max(float [],int); void search(float [],char [],int ,float); int p; int main() { int t; scanf(%d,t); int i; char ch[30]={0}; char a[30]={0}; float b[30]={0}; char f; for(i=0;it;i++) { f=getchar();

Re: [algogeeks] SPOJ ETF

2011-06-08 Thread kartik sachan
thanks legobut why preprocessing all time avoided?? any drawback of it? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] SPOJ ETF

2011-06-08 Thread saurabh singh
preprocessing is not at all a bad thing.There are certain problems where you can avoid TLE by preprocessing only.Examples include doing RMQ. But for this particular problem you are solving for all possible test cases only few of which actually occur,Moreover there is no big advantage drawn from

Re: [algogeeks] SPOJ ETF

2011-06-07 Thread kartik sachan
https://www.spoj.pl/problems/ETF/ vase saurabh bhai mere ho gya.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] SPOJ ETF

2011-06-07 Thread saurabh singh
For all those who are still stuck with TLE,dont preprocess.The test data is not that large and the time limit small.Just compute each query as it arrives.I got AC this way only On Tue, Jun 7, 2011 at 6:01 PM, kartik sachan kartik.sac...@gmail.comwrote: https://www.spoj.pl/problems/ETF/ vase

Re: [algogeeks] SPOJ ETF

2011-06-07 Thread Lego Haryanto
Also make sure you don't write this code during a technical interview ... allocating 8 million bytes on the stack is not the way to go. On Tuesday, June 7, 2011, saurabh singh saurab...@gmail.com wrote: For all those who are still stuck with TLE,dont preprocess.The test data is not that large

Re: [algogeeks] SPOJ ETF

2011-06-06 Thread saurabh singh
Can sum1 plz give me the link to the problem? 2011/6/5 keyan karthi keyankarthi1...@gmail.com also tc page tat arun said says as follows... 1. If *p* is prime, then φ (*p*) = *p* - 1 and φ (*pa*) = *p** a* * (1 - 1/*p*) for any *a*. 2. If *m* and *n* are coprime, then φ (*m* * *n*)

Re: [algogeeks] Spoj Problem Help

2011-06-05 Thread tec
The final sequence should be (0,0),(1,1),(2,3),(3,5),(5,8)... (0,0) and (0,1) both finishes in 0 iteration. (1,2)-(0,1) and (1,1)-(0,1) both finishes in 1 iteration. So (0,1) and (1,2) is discarded. For the rest: (0,1) - (1,2) - (2,3) - (3,5) - (5,8) - ... finishes in:

Re: [algogeeks] SPOJ ETF

2011-06-05 Thread keyan karthi
dude.. u code says pi(3) =3 as its a prime... but pi(3) is 2 in the same way pi(2)=2 as per ur code.. but ans is 1... mend ur code for this... :) On Sun, Jun 5, 2011 at 9:20 PM, kartik sachan kartik.sac...@gmail.comwrote: @keyan then also it is given time limit exceed i

Re: [algogeeks] SPOJ ETF

2011-06-05 Thread keyan karthi
also tc page tat arun said says as follows... 1. If *p* is prime, then φ (*p*) = *p* - 1 and φ (*pa*) = *p** a* * (1 - 1/*p*) for any *a*. 2. If *m* and *n* are coprime, then φ (*m* * *n*) = φ (*m*) * φ (*n*). 3. If *n* = , then Euler function can be found using formula: φ (*n*) =

Re: [algogeeks] SPOJ ETF

2011-06-04 Thread keyan karthi
first time when i pre processed, my code timed out :P on calling it for every loop iteration my code passed !! may be tats the problem... On Sun, Jun 5, 2011 at 1:56 AM, kartik sachan kartik.sac...@gmail.comwrote: @arun.i got nothing from this link becoz i have made the program

Re: [algogeeks] SPOJ ETF

2011-06-03 Thread arun kumar
read topcoder tutotial http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=primeNumbers hope will be useful On Fri, Jun 3, 2011 at 5:33 PM, kartik kartik.sac...@gmail.com wrote: what's worng in my code..why the judge is giving TLE.plzz help me out my code is #

[algogeeks] spoj problem acode

2011-06-01 Thread pacific :-)
Link : https://www.spoj.pl/problems/ACODE/ 25114 BEAN’, ‘BEAAD’, ‘YAAD’, ‘YAN’, ‘YKD’ ‘BEKD’. How many different decodings?” My soln , but i get TLE.Please help. #include iostream #include cstdio #include vector using namespace std; char * head; int result[5001]; int count(char * a ,int size)

Re: [algogeeks] spoj problem acode

2011-06-01 Thread arun kumar
hey me getting wrong ans..can anyone pls help me out here s my code #includestdio.h #includeiostream #includestring #includecstring using namespace std; unsigned long long a[5001]={0}; unsigned long long fun(string s,int n) { if(n==0) return 1; if(a[n]) return a[n]; int c=0,d=0;

Re: [algogeeks] spoj problem acode

2011-06-01 Thread keyan karthi
even if the left over string length is 1 so that the recursion can be fun(s,current_position-2), u still have the option for choosing a single character... do u get it?? thats where u go wrong... :) the rec call should be return fun(cur_length-1)+fun(cur_len-2) ... On Wed, Jun 1, 2011 at 3:34

[algogeeks] spoj -cornet disjoint sets suggestions!!

2011-06-01 Thread keyankarthi
http://spoj.pl/problems/CHAIN can any one suggest how to go about... animals can have only 3 different roots... how do u maintain it.. like u just came across a new animal.. how do u put it in a group.. this cant be done just by parent[i]==i stuff rite?? how to make sure that there is only 3

Re: [algogeeks] spoj problem acode

2011-06-01 Thread keyan karthi
oops.. :P that an if didnt notice tat :D On Wed, Jun 1, 2011 at 8:34 PM, keyan karthi keyankarthi1...@gmail.comwrote: even if the left over string length is 1 so that the recursion can be fun(s,current_position-2), u still have the option for choosing a single character... do u get it??

Re: [algogeeks] SPOJ Problem Help

2011-05-30 Thread oldman
Code::Blocks On Sun, May 29, 2011 at 1:59 AM, Akash Mukherjee akash...@gmail.com wrote: devcpp On Sat, May 28, 2011 at 11:17 PM, sravanreddy001 sravanreddy...@gmail.com wrote: Hi all. Can some one provide a good C editor.. preferable GUI one, that works on windows 7. I'm good with

[algogeeks] SPOJ Problem Help

2011-05-28 Thread Akshata Sharma
My code gives TLE. What further optimization is required in my code?? https://www.spoj.pl/problems/FACVSPOW/ /*FACVSPOW*/ #includestdio.h #includecmath using namespace std; int calc(long n, long a) { if(((n*log(n)-n)+0.5*log(2*M_PI*n)-n*log(a))=0) return 1; else return -1; } int main() {

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread Aakash Johari
Precompute the values. and then do queries. On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma akshatasharm...@gmail.comwrote: My code gives TLE. What further optimization is required in my code?? https://www.spoj.pl/problems/FACVSPOW/ /*FACVSPOW*/ #includestdio.h #includecmath using

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread sukhmeet singh
follow what Akash said..!! in case you still need help just go through http://ideone.com/al0U0 in devcpp..!! On Sat, May 28, 2011 at 2:34 PM, Aakash Johari aakashj@gmail.comwrote: Precompute the values. and then do queries. On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread Logic King
@sukhmeetyour code is having runtime error !! On Sat, May 28, 2011 at 4:48 AM, sukhmeet singh sukhmeet2...@gmail.comwrote: follow what Akash said..!! in case you still need help just go through http://ideone.com/al0U0 in devcpp..!! On Sat, May 28, 2011 at 2:34 PM, Aakash Johari

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread sukhmeet singh
don't see the online compiler.. it doesn't allow such a large array.. try on LINUX.. this is the one I got a/c on SPOJ ..!! http://ideone.com/NdBYJ On Sat, May 28, 2011 at 5:26 PM, Logic King crazy.logic.k...@gmail.comwrote: @sukhmeetyour code is having runtime error !! On Sat, May 28,

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread Akshata Sharma
thanks all :) On Sat, May 28, 2011 at 8:08 PM, sukhmeet singh sukhmeet2...@gmail.comwrote: don't see the online compiler.. it doesn't allow such a large array.. try on LINUX.. this is the one I got a/c on SPOJ ..!! http://ideone.com/NdBYJ On Sat, May 28, 2011 at 5:26 PM, Logic King

Re: [algogeeks] SPOJ Problem Help

2011-05-28 Thread sravanreddy001
Hi all. Can some one provide a good C editor.. preferable GUI one, that works on windows 7. I'm good with Java, but. now would like to get some hands on C, C++ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

[algogeeks] spoj TRAFICN- graph shortest path

2011-05-27 Thread keyankarthi
i'm trying to solve this problem.. https://www.spoj.pl/problems/TRAFFICN/ https://www.spoj.pl/problems/TRAFFICN/ here there are m edges.. in addition you are given k bi directional edges out of which u can choose only one bi directional or u choose none of the additional edges... aim is to

Re: [algogeeks] spoj--two squares problem

2011-05-26 Thread Ashish Goel
bool fn(const floatc) {//a^2+b^2=c if (sqr(sqrt(c)) == c) //perfect square { float a=1; float b=c-1; while(a=b){ float a2=a*a; float b2=b*b; if (a2+b2==c) return true; if (a*2+b2c) { a+=1;} else ( b-=1;} } } return false; } Best Regards Ashish Goel Think positive and

Re: [algogeeks] spoj--two squares problem

2011-05-26 Thread Balaji S
sqr(sqrt(c)) == c what ll it return if c is 10... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] spoj--two squares problem

2011-05-26 Thread saurabh singh
Depends on the parameter list of sqr function and also on type of c.If it takes double as parameter and returns double than false else true,Correct me if wrong,.. On Fri, May 27, 2011 at 8:56 AM, Balaji S balaji.ceg...@gmail.com wrote: sqr(sqrt(c)) == c what ll it return if c is 10... --

Re: [algogeeks] spoj--two squares problem

2011-05-25 Thread Saikat Debnath
I think your problem is you are using int. Use long long. On Thu, May 26, 2011 at 12:29 AM, ricky moon.afr...@gmail.com wrote: can anyone help me out with this problem: https://www.spoj.pl/problems/TWOSQRS/ It runs on my machine with this code but it gives wrong ans on their site.

Re: [algogeeks] spoj--two squares problem

2011-05-25 Thread subramania jeeva
Fermat's theorem will be better for this problem..:) Cheers ~ Jeeva ~ On Thu, May 26, 2011 at 12:42 AM, Saikat Debnath crazysai...@gmail.comwrote: I think your problem is you are using int. Use long long. On Thu, May 26, 2011 at 12:29 AM, ricky moon.afr...@gmail.com wrote:

Re: [algogeeks] spoj--two squares problem

2011-05-25 Thread Balaji S
Fermat's little theroem ??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more

Re: [algogeeks] spoj--two squares problem

2011-05-25 Thread subramania jeeva
see http://en.wikipedia.org/wiki/Fermat%27s_theorem_on_sums_of_two_squares Hope it'll help...:) Cheers ~ Jeeva ~ On Thu, May 26, 2011 at 9:17 AM, Balaji S balaji.ceg...@gmail.com wrote: Fermat's little theroem ??? -- You received this message because you are subscribed to

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread Akshata Sharma
@tec: the sequence should be like (0,1),(1,1),(1,2),(2,3),(3,5),(5,8)... or m i wrong? On Mon, May 23, 2011 at 11:08 AM, Aakash Johari aakashj@gmail.comwrote: Matrix exponentiation can help i think On Sun, May 22, 2011 at 10:36 PM, Akshata Sharma akshatasharm...@gmail.com wrote: It

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread sravanreddy001
@akshata, The (1,1) would be a special case. for give N=1, but again for N=1, (2,1) also satisfies well. And the series from then is constructed on the (1,0), (2,1), (3,2) So and so.. Also if you see in the original problem statement, they mentioned a=b, but not ab.. this is for the special

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread sravanreddy001
There is also another special case.. where N=0, in this case.. its (0,0) -- 0+0 = 0 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread anshu mishra
@sravanreddy001 suppose u have to calulate A^n u can calculate in O(d^3*log(n)); d is dimesion of matrixl while (n) { if (n1) mul(ans, A, d); mul(A, A, d); n =1; } -- Anshuman Mishra IIIT Allahabad -

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread Akshata Sharma
@sravanreddy001 by matrix exponential method, we can calculate the nth fibonacci number in logarithmic time. On Mon, May 23, 2011 at 7:39 PM, anshu mishra anshumishra6...@gmail.comwrote: @sravanreddy001 suppose u have to calulate A^n u can calculate in O(d^3*log(n)); d is dimesion of matrixl

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread Aakash Johari
@akshata, sravanreddy: yes, for more info regarding matrix expo. you can go through http://zobayer.blogspot.com/2010/11/matrix-exponentiation.html On Mon, May 23, 2011 at 7:28 AM, Akshata Sharma akshatasharm...@gmail.comwrote: @sravanreddy001 by matrix exponential method, we can calculate the

Re: [algogeeks] Spoj Problem Help

2011-05-23 Thread ankit sambyal
we can use the following formula to calculate the nth fibonacci no. in O(log n) time : fib(n)=round((pow(phi,n))/sqrt(5) + 1/2) where phi=(1+sqrt(5))/2; And by taking care of the special cases and by using the fact that the problem is just to find the (N+3)th fibonacci number for given N, we

[algogeeks] Spoj Problem Help

2011-05-22 Thread shady
Hey, Can anyone tell how to solve this problem in Spoj ? I went through some material but there all they were discussing was on complexity and not on actual number of iterations. http://www.spoj.pl/problems/MAIN74/ Thanks. -- You received this message because you are subscribed to the Google

Re: [algogeeks] Spoj Problem Help

2011-05-22 Thread tec
Try thinking backwards. (0,1),(1,2),(2,3),(3,5),(5,8),(8,13),... 2011/5/22 shady sinv...@gmail.com: Hey, Can anyone tell how to solve this problem in Spoj ? I went through some material but there all they were discussing was on complexity and not on actual number of iterations.

Re: [algogeeks] Spoj Problem Help

2011-05-22 Thread Akshata Sharma
It appers that the problem is just to find the (N+3)th fibonacci number for given N. Since N is very large, how to find nth fibonaci number for such a large n?? On Mon, May 23, 2011 at 7:51 AM, tec technic@gmail.com wrote: Try thinking backwards. (0,1),(1,2),(2,3),(3,5),(5,8),(8,13),...

Re: [algogeeks] Spoj Problem Help

2011-05-22 Thread Aakash Johari
Matrix exponentiation can help i think On Sun, May 22, 2011 at 10:36 PM, Akshata Sharma akshatasharm...@gmail.comwrote: It appers that the problem is just to find the (N+3)th fibonacci number for given N. Since N is very large, how to find nth fibonaci number for such a large n?? On Mon,

[algogeeks] SPOJ problem: HASHIT

2011-05-20 Thread ankit sambyal
Hey guys , I am getting wrong answer in : http://www.spoj.pl/problems/HASHIT/. Somebdy plz check it out or provide some test cases. This code works fine with the test cases provided and even my own test cases. The following is my code: #includestdio.h #includestring.h int main() { int

[algogeeks] spoj-lites

2011-05-08 Thread keyankarthi
this is my code -- #includeiostream #includevector #includestring.h using namespace std; vectorint tbf(100,0),array(100,0); //vector 'tbf' denotes tobeflipped void make(int ptr,int b,int e) { if(b==e) { array[ptr]=0;

[algogeeks] SPOJ Problem : PALIN

2011-03-28 Thread ankit sambyal
I m getting WA in this question though all the test cases are giving correct output. Link to the problem : https://www.spoj.pl/problems/PALIN/ Can anybdy check out my code . The following is my code : #includestdio.h #includestring.h int compare(char s[], char t[]) { //only check second

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-26 Thread sukhmeet singh
Bharath can u tell me how u came with the combine function ??? I can't understand the logic behind it ... do reply On Wed, Mar 16, 2011 at 10:24 PM, Bharath 2009503507 CSE bharathgo...@gmail.com wrote: i am new to segment trees..i tried this problem in spoj..

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-26 Thread bharath kannan
i already mentioned the link where i got this approach.. //from spoj forum I have tried this problem with the following approach:- 1. any expression can be expressed as ))...)+a_correct_expression+((...( 2.at each node i am storing 1.no_of ')' at start and 2.no_of '(' at end of expression that

Re: [algogeeks] SPOJ problem

2011-03-25 Thread sukhmeet singh
try using precomputation in a better way ...this got me AC.. rest is just binary search function ...!!! On Thu, Mar 24, 2011 at 9:06 PM, .bashrc saurab...@gmail.com wrote: Has anyone solved this problem-https://www.spoj.pl/problems/FACVSPOW/ I am getting TLE using binary search. Thanks in

Re: [algogeeks] SPOJ problem

2011-03-25 Thread saurabh singh
I am very sorry but i dont think i got your point.You suggesting interpolation? Kindly suggest some reference for good precomputation techniques.. Thanks in advance -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] SPOJ problem

2011-03-24 Thread .bashrc
Has anyone solved this problem-https://www.spoj.pl/problems/FACVSPOW/ I am getting TLE using binary search. Thanks in advance -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] SPOJ NUMGUESS

2011-03-23 Thread bharath kannan
I guess you solve it using binary search.. On Wed, Mar 23, 2011 at 6:48 PM, Vishnutej mylavarapu.vishnu...@gmail.comwrote: Hello everyone, Im unable to understand the NUMGUESS problem in SPOJ.Can some one explain what the problem is about? Thanks in advance. -Vishnutej.Mylavarapu --

Re: [algogeeks] SPOJ NUMGUESS

2011-03-23 Thread saurabh singh
Yup...Its a binary search problem,Check wiki page of binary search for the same problem On Wed, Mar 23, 2011 at 8:14 PM, bharath kannan bharathgo...@gmail.comwrote: I guess you solve it using binary search.. On Wed, Mar 23, 2011 at 6:48 PM, Vishnutej mylavarapu.vishnu...@gmail.com wrote:

Re: [algogeeks] Spoj-merectcnt

2011-03-20 Thread Ankur Khurana
problem ka link bhi diya karo ya code.. On Sun, Mar 20, 2011 at 3:34 AM, sunny sunny.verma...@gmail.com wrote: hello frnds... i am getting TLE in 12th test case .. can anyone over ther help me to shorten it.. #includestdio.h #includeiostream using namespace std; int gcd(int a, int

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread murthy.krishn...@gmail.com
@anurag accor to me the output must be YES, correct me if I am wrong On Sun, Mar 20, 2011 at 10:40 AM, bharath kannan bharathgo...@gmail.comwrote: i thot tat i had some mistake in my code and typed it all over again.. finally i noticed this :) On Sat, Mar 19, 2011 at 12:12 AM, Kunal Patil

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread bharath kannan
@murthy:no..the op must be NOits not a valid expression..read the two conditions for a valid expression.. On Sun, Mar 20, 2011 at 8:23 PM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: @anurag accor to me the output must be YES, correct me if I am wrong On Sun, Mar 20,

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread murthy.krishn...@gmail.com
@bharath yaa now I got the ques, thanx :-) On Mon, Mar 21, 2011 at 4:47 AM, bharath kannan bharathgo...@gmail.comwrote: @murthy:no..the op must be NOits not a valid expression..read the two conditions for a valid expression.. On Sun, Mar 20, 2011 at 8:23 PM, murthy.krishn...@gmail.com

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread Anurag atri
@krishna - yeah as Bharath said that case should give NO , anyways you got it now :) On Mon, Mar 21, 2011 at 5:50 AM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: @bharath yaa now I got the ques, thanx :-) On Mon, Mar 21, 2011 at 4:47 AM, bharath kannan

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-20 Thread murthy.krishn...@gmail.com
Thanks 2 all On Mon, Mar 21, 2011 at 9:19 AM, Anurag atri anu.anurag@gmail.comwrote: @krishna - yeah as Bharath said that case should give NO , anyways you got it now :) On Mon, Mar 21, 2011 at 5:50 AM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: @bharath yaa now I

[algogeeks] SPOJ problem- TRICOUNT

2011-03-19 Thread cegprakash
Here is my code for TRICOUNT problem //http://www.spoj.pl/problems/TRICOUNT/ //cegprak...@gmail.com #includeiostream #includeconio.h using namespace std; unsigned long long start,end,arr[101],arr2[101]; //number of triangles facing upwards=arr //number of triangles facing downwards=arr2

Re: [algogeeks] SPOJ problem- TRICOUNT

2011-03-19 Thread sukhmeet singh
may be u can try to find a more general formula for the series..which just depends on 'n'... On Sat, Mar 19, 2011 at 11:48 PM, cegprakash cegprak...@gmail.com wrote: Here is my code for TRICOUNT problem //http://www.spoj.pl/problems/TRICOUNT/ //cegprak...@gmail.com #includeiostream

[algogeeks] Spoj-merectcnt

2011-03-19 Thread sunny
hello frnds... i am getting TLE in 12th test case .. can anyone over ther help me to shorten it.. #includestdio.h #includeiostream using namespace std; int gcd(int a, int b) { if(b==0) return(a); else return gcd(b,a%b); } int main() { int rec,g,count=0; scanf(%d,rec);

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-19 Thread bharath kannan
i thot tat i had some mistake in my code and typed it all over again.. finally i noticed this :) On Sat, Mar 19, 2011 at 12:12 AM, Kunal Patil kp101...@gmail.com wrote: Hey.. I also got into same trouble today... I submitted it 6 times..then got bored and de moralised cause i cudnt find

[algogeeks] SPOJ Problem : PRIME1

2011-03-18 Thread samby
The problem goes like this : Peter wants to generate some prime numbers. Your task is to generate all prime numbers between two given numbers! Input The input begins with the number t of test cases in a single line (t=10). In each of the next t lines there are two numbers m and n (1 = m = n =

Re: [algogeeks] SPOJ Problem : PRIME1

2011-03-18 Thread Anurag atri
you should try sieve of eratosthenes http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes there are far more efficient algorithms but i think this shoild be a good one to start with . ( even i got AC with this one :) ) On Fri, Mar 18, 2011 at 10:11 PM, samby ankitsamb...@gmail.com wrote: The

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-18 Thread Kunal Patil
Hey.. I also got into same trouble today... I submitted it 6 times..then got bored and de moralised cause i cudnt find flaw in code... When i read your mail and corresponding sorry mail...it just struck me..I also had to print YES and NOand i was printing NO as NoIt got ac den... :P thnx

Re: [algogeeks] SPOJ problem-BRCKTS

2011-03-17 Thread bharath kannan
sorry guyz... Had to print YES n NO.. i printed as Yes n No... Got ac.. Sorry for the trouble.. On Wed, Mar 16, 2011 at 10:24 PM, Bharath 2009503507 CSE bharathgo...@gmail.com wrote: i am new to segment trees..i tried this problem in spoj.. http://www.spoj.pl/problems/BRCKTS am getting WA..

[algogeeks] SPOJ problem-BRCKTS

2011-03-16 Thread Bharath 2009503507 CSE
i am new to segment trees..i tried this problem in spoj.. http://www.spoj.pl/problems/BRCKTS am getting WA.. pls help... code: #includeiostream #includevector #includecstdio #includecmath #includestring using namespace std; class pi { public: int a,b; pi()

Re: [algogeeks] spoj problem

2011-03-15 Thread UTKARSH SRIVASTAV
well i have a doubt the test case says number could be as large as 10 and you have taken int but int does not have such range then how it is accepted On Sat, Mar 12, 2011 at 7:57 PM, Logic King crazy.logic.k...@gmail.comwrote: Here is my solution.i got it AC #includestdio.h int

Re: [algogeeks] spoj problem

2011-03-15 Thread Logic King
i Agree.the test cases for which problem is being jugdged might not have those larger values. On Tue, Mar 15, 2011 at 12:20 PM, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: well i have a doubt the test case says number could be as large as 10 and you have taken int but

Re: [algogeeks] spoj problem

2011-03-15 Thread Ankur Khurana
@utraksh : 10^9 is well in int limits On Tue, Mar 15, 2011 at 12:56 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote: @utkarsh:teri kismat acchi thi aur kuch nhimaze kar! --- Satyam Kapoor B.Tech-2nd Year MNNIT-Allahabad. -- You received this message because

Re: [algogeeks] Spoj Problem

2011-03-15 Thread Balaji Ramani
It fails for input 1,2,3. I think there needs to be one more iteration to check if the candidate is actually a majority element or not. Thanks, Balaji. On Tue, Mar 15, 2011 at 9:50 PM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: CAN ANYONE PLEASE TELL ME WHY MY CODE IS GIVING WRONG

Re: [algogeeks] Spoj Problem

2011-03-15 Thread Akshata Sharma
hey link to the problem?? On Tue, Mar 15, 2011 at 10:50 PM, Balaji Ramani rbalaji.psgt...@gmail.comwrote: It fails for input 1,2,3. I think there needs to be one more iteration to check if the candidate is actually a majority element or not. Thanks, Balaji. On Tue, Mar 15, 2011 at 9:50

Re: [algogeeks] Spoj Problem

2011-03-15 Thread Balaji Ramani
http://www.spoj.pl/problems/MAJOR/ http://www.spoj.pl/problems/MAJOR/Thanks, Balaji. On Tue, Mar 15, 2011 at 11:00 PM, Akshata Sharma akshatasharm...@gmail.comwrote: hey link to the problem?? On Tue, Mar 15, 2011 at 10:50 PM, Balaji Ramani rbalaji.psgt...@gmail.com wrote: It fails for

Re: [algogeeks] Spoj Problem

2011-03-15 Thread UTKARSH SRIVASTAV
tahnks balaji i have got ac in this problem my prog is same only in the end i have taken a loop and @ akshata the link for the prob is https://www.spoj.pl/problems/MAJOR/ MY CODE IS #includestdio.h main() { long long int n,t,r[100],count,major,i; scanf(%lld,t); while(t--) {

Re: [algogeeks] SPoj maximum sum subseuence

2011-03-15 Thread Nikhil Jindal
Hey Ankur, Why dont u just modify the findx function itself to return the frequency of occurence of maxsum as well. On Sun, Mar 13, 2011 at 12:26 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: https://www.spoj.pl/problems/MAXSUMSQ/ Hi in above problem , i am getting TLE but according to

Re: [algogeeks] SPOJ PROBLEM

2011-03-15 Thread Algoose chase
Can you explain your code ? On Thu, Mar 10, 2011 at 10:22 AM, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: WELL I HAVE DONE THIS PROBLEM .HERE IS THE CODE #includestdio.h #includealgorithm using namespace std; main() { long long int t[2][2010],price[2010],r,c,i,j,n;

Re: [algogeeks] SPoj maximum sum subseuence

2011-03-14 Thread tech rascal
@ankur: can u plz xplain ur approach?? On Sun, Mar 13, 2011 at 12:26 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: https://www.spoj.pl/problems/MAXSUMSQ/ Hi in above problem , i am getting TLE but according to given contraints , i think my code is good enough to run. Can any body help me

Re: [algogeeks] SPoj maximum sum subseuence

2011-03-14 Thread keyan karthi
i used the following code.. getting wa #includeiostream #includealgorithm #includevector #includelimits.h #includemap using namespace std; typedef unsigned long long int ull; int main() { int t; cint; while(t--) { int n,sm=0; scanf(%d,n); vectorint v(n); mapint,int mp; for(int i=0;in;i++)

[algogeeks] Spoj Problem : String based

2011-03-13 Thread Logic King
I tried the problem https://www.spoj.pl/problems/NHAY/ I didn't Understand the Input of the problem -- The length of the needle is only limited by the memory available to your program, so do not make any assumptions - instead, read the length and allocate memory as needed. The haystack is *not*

Re: [algogeeks] Spoj Problem : String based

2011-03-13 Thread sukhmeet singh
in order to deal with such situations u have to read the input till the end of file if your algo is correct then using EOF something like while(scanf(%d,n)!=EOF) will give u AC..!! On Sun, Mar 13, 2011 at 2:01 PM, Logic King crazy.logic.k...@gmail.comwrote: I tried the problem

Re: [algogeeks] Spoj Problem : String based

2011-03-13 Thread Logic King
U didn't understand my problem.i have the problem with this line -- The length of the needle is only limited by the memory available to your program, so do not make any assumptions - instead, read the length and allocate memory as needed. On Sun, Mar 13, 2011 at 4:00 PM, sukhmeet singh

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
Any faster way to solve this problem?? On 3/12/11, Balaji Ramani rbalaji.psgt...@gmail.com wrote: Yes, the correct answer is 0. if(flag ==0 || ans ==0) i think can be changed to if(flag ==0) alone. Thanks, Balaji. On Sat, Mar 12, 2011 at 10:16 AM, Satyam Kapoor

Re: [algogeeks] spoj problem

2011-03-12 Thread Balaji Ramani
Find the gcd of n-1 differences ( a[1]..a[n-1] with a[0] ) ans = (a[n-1] - a[0])/gcd - n + 1 Thanks, Balaji. On Sat, Mar 12, 2011 at 2:00 PM, Akshata Sharma akshatasharm...@gmail.comwrote: Any faster way to solve this problem?? On 3/12/11, Balaji Ramani rbalaji.psgt...@gmail.com wrote:

Re: [algogeeks] spoj problem

2011-03-12 Thread Satyam Kapoor
this is gud but not the best soln. -- Satyam Kapoor B.Tech 2nd year Computer Science And Engineering M.N.N.I.T ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
@Ankur: then what is the 'best' solution for this? :) @Balaji: i tried implementing but I dont know which case it fails?? getting WA now!! Here is the code: #includestdio.h int main() { long n,gcd=1; scanf(%d,n); long long a[n],b[n],cnt=0,sum=0; long long min=9; scanf(%lld,a[0]);

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
sorry, @satyam: then what is the 'best' solution for this? :) On Sat, Mar 12, 2011 at 7:06 PM, Akshata Sharma akshatasharm...@gmail.comwrote: @Ankur: then what is the 'best' solution for this? :) @Balaji: i tried implementing but I dont know which case it fails?? getting WA now!! Here is the

Re: [algogeeks] spoj problem

2011-03-12 Thread Satyam Kapoor
@akshata:i did this one by hcf method but it took too much time... -- Satyam Kapoor B.Tech 2nd year Computer Science And Engineering M.N.N.I.T ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] spoj problem

2011-03-12 Thread Akshata Sharma
@Balaji: that WA was due to using int in place of long long in loop. But still, this is giving TLE. On Sat, Mar 12, 2011 at 7:07 PM, Akshata Sharma akshatasharm...@gmail.comwrote: sorry, @satyam: then what is the 'best' solution for this? :) On Sat, Mar 12, 2011 at 7:06 PM, Akshata Sharma

<    1   2   3   >