[algogeeks] Re: spoj problem EASYMATH

2012-09-27 Thread gaurav yadav
thanx :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/iy_uho_bmMYJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from

[algogeeks] Re: spoj problem EASYMATH

2012-09-26 Thread gaurav yadav
an idea of the approach would be enough.. plz help.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/3H3O2K4KBBMJ. To post to this group, send email

[algogeeks] Re: spoj problem : POKER

2012-06-18 Thread Mayank Singh
it also ran successfully on ideone.com plz help me i am classifying the card in two parts: one with same suit and other with different suit... plz let me know if futher explanation is needed abt the code help me regarding this.. thanx -- You received this message because you are subscribed

Re: [algogeeks] Re: spoj problem : POKER

2012-06-18 Thread Pranjal Patil
Your code fails on one of the test cases like 5H 6H 7H 8H 9H. it should give straight flush instead of flush, Think of all such cases are change accordingly .. On Mon, Jun 18, 2012 at 10:01 PM, Mayank Singh singh13490may...@gmail.com wrote: it also ran successfully on ideone.com plz help me i

[algogeeks] Re: spoj problem

2012-06-13 Thread shiv narayan
will be better if you post on spoj forums.!! On Wednesday, 13 June 2012 01:40:36 UTC+5:30, gaurav yadav wrote: plz nyone explain how to approach this problem.. http://www.spoj.pl/problems/XORROUND/ -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Re: spoj problem

2012-06-13 Thread saurabh singh
No this is fair enough.It directly involves algorithm. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Thu, Jun 14, 2012 at 4:28 AM, shiv narayan narayan.shiv...@gmail.comwrote: will be better if you post on spoj forums.!! On Wednesday, 13 June 2012

Re: [algogeeks] Re: spoj problem

2012-06-13 Thread Sourabh Singh
@ saurabh singh : what algorithm can be used ?? coz.. i did it by simple observation. 1) just take any sequence of numbers. 2) write it's first 5-6 xor round's. 3) now luk for some pattern. u'll get the answer : ) On Wed, Jun 13, 2012 at 9:46 PM, saurabh singh saurab...@gmail.com

Re: [algogeeks] Re: spoj problem

2012-05-15 Thread ashish pant
@lucifer nice approach for calculating median.. thanks for the help -- 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] Re: spoj problem

2012-05-14 Thread Lucifer
O(n) approach for finding the height of the stacks.. - First take 2 arrays A[n] and B[n], where A keeps track of the no. of times a start index(the start query index) occurs. and B keeps track of the no. of times a end index(the end query index)

Re: [algogeeks] Re: spoj problem

2011-11-18 Thread Amol Sharma
don't bother got AC was doing lot of extra overhead -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99 On Fri, Nov

Re: [algogeeks] Re: spoj problem

2011-11-17 Thread Anshul AGARWAL
finally got AC,(using bfs) thanx DON for provide such nice test case *Anshul Agarwal Nit Allahabad Computer Science** * On Wed, Nov 16, 2011 at 8:14 PM, SAMMM somnath.nit...@gmail.com wrote: U need to check for the case when (s==g) source and destination are same , I got stuck here , after

Re: [algogeeks] Re: spoj problem

2011-11-16 Thread UTKARSH SRIVASTAV
hi don i have now implemented it with bfs but it's still giving wrong answer can you please tell the test case #includestdio.h int a[1000100][2]; int visited[1000100],i,q[1000100]; int main() { int f,s,g,u,d; scanf(%d%d%d%d%d,f,s,g,u,d); for( i = 1 ; i = f;i++) { if(i + u

Re: [algogeeks] Re: spoj problem

2011-11-16 Thread Anshul AGARWAL
thanx Don. i think my logic is not so good . now i try to make it using bfs . *Anshul Agarwal Nit Allahabad Computer Science** * On Tue, Nov 15, 2011 at 5:36 PM, Don dondod...@gmail.com wrote: This input 100 1 5 5 91 Should output 20. Yours says Take the stairs. 100 1 5 5 89 Should

Re: [algogeeks] Re: spoj problem

2011-11-15 Thread UTKARSH SRIVASTAV
hi don please tell me where am i wrong in this maths in solving this question. let x = number of times to press up button let y = number of times to press down button k = g -s so we have u*x - d*y = k ---(1) we have to minimize x + y so from (1) x = (k+d*y)/u; x +

[algogeeks] Re: spoj problem

2011-11-15 Thread Don
I don't think that your solution assures that the elevator stays in its bounds. Don On Nov 15, 12:49 pm, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: hi don please tell me where am i wrong in this maths in solving this question.      let x = number of times to press up button let y =  

[algogeeks] Re: spoj problem

2011-11-15 Thread Don
This input 100 1 5 5 91 Should output 20. Yours says Take the stairs. 100 1 5 5 89 Should output 76. Yours says Take the stairs. Don On Nov 14, 8:27 am, Anshul AGARWAL anshul.agarwa...@gmail.com wrote: problem ishttp://www.spoj.pl/problems/ELEVTRBL/ and my solution is give wrong answer on

[algogeeks] Re: spoj problem

2011-11-14 Thread Don
I solved this one with a breadth-first search. Don On Nov 14, 8:27 am, Anshul AGARWAL anshul.agarwa...@gmail.com wrote: problem ishttp://www.spoj.pl/problems/ELEVTRBL/ and my solution is give wrong answer on spoj . Plz help me to find in which case my solution give wrong answer. *

[algogeeks] Re: SPOJ problem

2011-09-17 Thread Dave
@Amrit: You only have 2 and 3 litre jars. You are trying to get 4 litres into one of them. There is no 4 litre jar, nor any other vessel into which you can capture the 4 litres. Dave On Sep 17, 6:15 am, amrit harry dabbcomput...@gmail.com wrote: http://www.spoj.pl/problems/POUR1/ hw the 2nd

Re: [algogeeks] Re: SPOJ problem

2011-09-17 Thread amrit harry
@dave +1 On Sat, Sep 17, 2011 at 8:10 PM, Dave dave_and_da...@juno.com wrote: @Amrit: You only have 2 and 3 litre jars. You are trying to get 4 litres into one of them. There is no 4 litre jar, nor any other vessel into which you can capture the 4 litres. Dave On Sep 17, 6:15 am, amrit

[algogeeks] Re: SPOJ Problem DP

2011-07-03 Thread shady
any spojjer in the group ? if you want i can post my solution with djikstra's :P ? Shady On Sat, Jul 2, 2011 at 10:31 AM, shady sinv...@gmail.com wrote: Hi, I am solving this http://www.spoj.pl/problems/DP/ problem using Djikstra's algorithm. What is the dynamic programming solution to this

[algogeeks] Re: spoj problem chairs

2011-06-22 Thread VIHARRI
@saurabh : The answer suggested by you is for not all together... -- 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] Re: spoj problem chairs

2011-06-21 Thread shady
what will be the dynamic programming solution to the above problem ? can anyone explain the states of the dp ? On Mon, Jun 20, 2011 at 6:53 PM, oppilas . jatka.oppimi...@gmail.comwrote: I think you have not read the question carefully. Please read it again and try to ans for small values of

Re: [algogeeks] Re: spoj problem chairs

2011-06-21 Thread keyan karthi
dp(int chair,int person,bool previous) if(previous) dp(chair-1,person,0) else dp(chair-1,person-1,1)+dp(chair-1,person,0) with basic conditions as it is a circle.. if person is placed in first chair u cant place a person in last chair On Tue, Jun 21, 2011 at 7:38 PM,

[algogeeks] Re: spoj problem chairs

2011-06-20 Thread RITESH SRIVASTAV
@Saurabh Your formula is incorrect. for input : 5 2 the answer should be 5 but your program gives 12 as output. On Jun 19, 11:35 pm, abc abc may.i.answ...@gmail.com wrote: @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

Re: [algogeeks] Re: spoj problem chairs

2011-06-20 Thread oppilas .
I think you have not read the question carefully. Please read it again and try to ans for small values of n,k first. for k=1, answer will be always 1. On Mon, Jun 20, 2011 at 6:31 PM, saurabh singh saurab...@gmail.com wrote: O.K can anyone suggest the combinatorial solution.I thought it this

Re: [algogeeks] Re: SPOJ problem- TRICOUNT

2011-06-04 Thread Anirudh S
I am still working on arriving at a recursive solution but these links might help. http://mathworld.wolfram.com/TriangleTiling.html http://oeis.org/A002717 http://oeis.org/A002717 On Mon, Mar 21, 2011 at 5:50 PM, cegprakash cegprak...@gmail.com wrote: hello... someone plz tell me how to arrive

[algogeeks] Re: SPOJ problem- TRICOUNT

2011-06-04 Thread Dave
Also http://www.mathematik.uni-bielefeld.de/~sillke/SEQUENCES/grid-triangles. Dave On Jun 4, 8:28 am, Anirudh S anirudh24se...@gmail.com wrote: I am still working on arriving at a recursive solution but these links might help. http://mathworld.wolfram.com/TriangleTiling.html

Re: [algogeeks] Re: Spoj Problem Help

2011-05-24 Thread ankit sambyal
@Balaji : By using Dave's algo it gives TLE and it should be ...try taking n as large as 10^18. How did u reduce the no. of iterations in this case ?? On Mon, May 23, 2011 at 9:07 PM, Balaji S balaji.ceg...@gmail.com wrote: @Dave: nice idea.. ll this give AC ? -- You received this

Re: [algogeeks] Re: Spoj Problem Help

2011-05-24 Thread sravanreddy001
@Dave,Balaji,Samby.. Without the matrix exponentiation, the time is not possible, and without using the intermediate modulo operater as suggested by Dave, the value cannot be accommodated, as the 300th fibinocci number alone comes to --

Re: [algogeeks] Re: Spoj Problem Help

2011-05-24 Thread Aakash Johari
It's done. Today I tried it. Simply for N=0 and N=1 answer is (0,0) = 0 and (1,1)=2 respectively. For other cases, you can get the solution with fib(N+3). Starting fib(1) = 1, fib(2) = 1... Matrix Exponentiation, and Modulus for given constraints are necessary to pass the solution. On Mon,

Re: [algogeeks] Re: Spoj Problem Help

2011-05-24 Thread Logic King
@aakash the cases are clear but can you explain how you did the matrix exponentiation part ??..explain plz...i'm not getting it... On Tue, May 24, 2011 at 1:25 AM, Aakash Johari aakashj@gmail.comwrote: It's done. Today I tried it. Simply for N=0 and N=1 answer is (0,0) = 0 and (1,1)=2

[algogeeks] Re: Spoj Problem Help

2011-05-23 Thread Dave
@Akshata: Actually, you only need to find the n+3rd Fibonacci number, modulus 17. This saves you from having to deal with big integers. Something like this should do for the calculation, assuming that long long int is 64 bits: long long int n; int a = 1, b = 2, c; for(i = 0; i n, i++) {

[algogeeks] Re: Spoj Problem Help

2011-05-23 Thread Dave
Replying to my own posting! Even better, since it replaces the relatively slow modulus operation with a comparison and subtraction: long long int n; int a = 1, b = 2, c; for(i = 0; i n, i++) { c = a + b; a = b; b = c 17 ? c : c - 17; } // b is the result Dave On

Re: [algogeeks] Re: Spoj Problem Help

2011-05-23 Thread Balaji S
@Dave: nice idea.. ll this give AC ? -- 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

Re: [algogeeks] Re: SPOJ problem

2011-04-01 Thread saurabh singh
Its failing after running for 0.74 seconds in c..May be precision problem?What value of E and PI we should use? -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Re: SPOJ problem

2011-03-31 Thread КоЦіК
On Apr 1, 6:45 am, saurabh singh saurab...@gmail.com wrote: Sorry for ignorance but i didnt got what *1d* means in the formula It is from Java code means 1 should be seen as double 1.0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] Re: SPOJ problem

2011-03-29 Thread КоЦіК
Formula: Math.E*a-0.5*Math.log(2*Math.PI*a)-1d/a gives right result almost always besides (a:n:formula value): 3 : 7 : 6 195 : 526 : 527 534 : 1447 : 1448 580 : 1572 : 1573 1168 : 3170 : 3171 1870 : 5078 : 5079 2175 : 5907 : 5908 2590 : 7035 : 7036 2927 : 7951 : 7952 3225 : 8761 : 8762 3892 :

Re: [algogeeks] Re: Spoj Problem

2011-03-27 Thread sukhmeet singh
is there a better solution than O(n) ??? any datastructure possible On Wed, Mar 23, 2011 at 8:20 PM, .bashrc saurab...@gmail.com wrote: I may be wrong but if no==1000 then it becomes a[100] which is beyond your array limit On Mar 18, 12:31 am, KK kunalkapadi...@gmail.com wrote: i m

Re: [algogeeks] Re: Spoj Problem

2011-03-27 Thread saurabh singh
I dont think so even if a solution which appears to be better than o(n) can actually be better.Because with this approach we are working upon each input test case rather than storing them somewhere and traversing it again.The only way this program can be improoved is in terms of memory i feel. On

Re: [algogeeks] Re: Spoj Problem

2011-03-27 Thread saurabh singh
Plz correct me if i am wrong On Sun, Mar 27, 2011 at 4:50 PM, saurabh singh saurab...@gmail.com wrote: I dont think so even if a solution which appears to be better than o(n) can actually be better.Because with this approach we are working upon each input test case rather than storing them

[algogeeks] Re: SPOJ problem

2011-03-26 Thread tec
Try precomputing the results for all possible a using mathematical method, which should be O(N) (N=10^6) in total. Then answer each query in O(1) (there can be 10 queries). On Mar 26, 12:20 pm, saurabh singh saurab...@gmail.com wrote: I am very sorry but i dont think i got your point.You

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-23 Thread bharath kannan
i found this good.. http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor On Mon, Mar 21, 2011 at 6:02 PM, Anurag atri anu.anurag@gmail.comwrote: yes , please suggest a nice tutorial for segment trees .. On Mon, Mar 21, 2011 at 5:48 PM, cegprakash

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-23 Thread bharath kannan
but..i read this oly after my senior taught me segment trees.. On Wed, Mar 23, 2011 at 4:43 PM, bharath kannan bharathgo...@gmail.comwrote: i found this good.. http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor On Mon, Mar 21, 2011 at 6:02 PM, Anurag atri

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-23 Thread Arpit Sood
in the topcoder tutorial of the segment trees, the value of the M[node] should be modified during query, we only need to return it. Just a correction, people have mentioned it in forum also. On Wed, Mar 23, 2011 at 4:46 PM, bharath kannan bharathgo...@gmail.comwrote: but..i read this oly after

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-23 Thread Arpit Sood
oops, i mean it shouldn't be modified. On Wed, Mar 23, 2011 at 6:56 PM, Arpit Sood soodfi...@gmail.com wrote: in the topcoder tutorial of the segment trees, the value of the M[node] should be modified during query, we only need to return it. Just a correction, people have mentioned it in

[algogeeks] Re: Spoj Problem

2011-03-23 Thread .bashrc
I may be wrong but if no==1000 then it becomes a[100] which is beyond your array limit On Mar 18, 12:31 am, KK kunalkapadi...@gmail.com wrote: i m getting TLE for this soln and m not getting the concept used in the above soln can anyone help?? #includeiostream using namespace std;

[algogeeks] Re: SPOJ problem-BRCKTS

2011-03-21 Thread cegprakash
hey i want to learn segment trees.. suggest me a tutorial plz.. pdf or word anything.. i don't understand wiki page -- 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

[algogeeks] Re: SPOJ problem- TRICOUNT

2011-03-21 Thread cegprakash
hello... someone plz tell me how to arrive @ that formula.. -- 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] Re: SPOJ problem-BRCKTS

2011-03-21 Thread Anurag atri
yes , please suggest a nice tutorial for segment trees .. On Mon, Mar 21, 2011 at 5:48 PM, cegprakash cegprak...@gmail.com wrote: hey i want to learn segment trees.. suggest me a tutorial plz.. pdf or word anything.. i don't understand wiki page -- You received this message because you are

[algogeeks] Re: SPOJ problem- TRICOUNT

2011-03-20 Thread cegprakash
now tell how u arrive at this formula? On Mar 20, 6:25 am, Dave dave_and_da...@juno.com wrote: Oops. Sorry. The correct formula is n*(n+2)*(2*n+1)/8. Dave On Mar 19, 5:26 pm, sunny sunny.verma...@gmail.com wrote: this formula is giving wrong!!!.. :( can u pls tell the approach -- You

[algogeeks] Re: SPOJ problem-BRCKTS

2011-03-19 Thread cegprakash
could someone plz help me with a pdf for learning segment tree? i don't understand the wiki page -- 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,

[algogeeks] Re: SPOJ problem-BRCKTS

2011-03-19 Thread cegprakash
could someone plz help me with a pdf for learning segment tree? i don't understand the wiki page -- 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,

[algogeeks] Re: SPOJ Problem : PRIME1

2011-03-19 Thread Dennisbot
why not use the criba of Eratóstenes? On 18 mar, 11:41, samby ankitsamb...@gmail.com wrote: 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

[algogeeks] Re: SPOJ problem- TRICOUNT

2011-03-19 Thread cegprakash
i've modified my algorithm but i'm getting wrong answer. someone help.. #includeiostream using namespace std; unsigned long long start,end,arr[101],arr2[101]; int main(){ int j,t,i,n; for(i=0;i100;i++){ arr[i]=i+1+arr[i-1]; } for(i=0;i100;i++) { arr[i]+=arr[i-1]; } arr2[1]=1;

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-19 Thread murthy.krishn...@gmail.com
can any 1 explain why we have 2 use segment trees ?? I am under the impression that in order to distinguish correct bracket expressions, we can just count the number of left brackets and compare that with the number of right brackets, if they are equal then it is a correct bracket expression.

[algogeeks] Re: SPOJ problem- TRICOUNT

2011-03-19 Thread Dave
Isn't the number of triangles in level n just n*(n^2 + 6 n - 1)/6? Dave On Mar 19, 2:47 pm, cegprakash cegprak...@gmail.com wrote: i've modified my algorithm but i'm getting wrong answer. someone help.. #includeiostream using namespace std; unsigned long long

[algogeeks] Re: SPOJ problem- TRICOUNT

2011-03-19 Thread sunny
this formula is giving wrong!!!.. :( can u pls tell the approach -- 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] Re: SPOJ problem- TRICOUNT

2011-03-19 Thread cegprakash
my algo is working fine.. got acc:) :) small error :P -- 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] Re: SPOJ problem- TRICOUNT

2011-03-19 Thread Dave
Oops. Sorry. The correct formula is n*(n+2)*(2*n+1)/8. Dave On Mar 19, 5:26 pm, sunny sunny.verma...@gmail.com wrote: this formula is giving wrong!!!.. :( can u pls tell the approach -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-19 Thread Anurag atri
@Krishna }{ what about this case ? On Sun, Mar 20, 2011 at 2:11 AM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: can any 1 explain why we have 2 use segment trees ?? I am under the impression that in order to distinguish correct bracket expressions, we can just count the

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-19 Thread bharath kannan
http://www.spoj.pl/forum/viewtopic.php?f=3t=5240p=20667hilit=BRCKTS#p20667 if u know d basics of segment tree..then this thread will help for solving this prob :) On Sun, Mar 20, 2011 at 2:11 AM, murthy.krishn...@gmail.com murthy.krishn...@gmail.com wrote: can any 1 explain why we have 2 use

[algogeeks] Re: Spoj Problem

2011-03-17 Thread KK
i m getting TLE for this soln and m not getting the concept used in the above soln can anyone help?? #includeiostream using namespace std; int main() { int t,n,k,no,flag; scanf(%d,t); while(t--) { scanf(%d,n); k = n; int a[100] = {0};

Re: [algogeeks] Re: SPOJ Problem

2011-03-16 Thread Akshata Sharma
use suffix tree :) On Sun, Mar 6, 2011 at 10:29 PM, Logic King crazy.logic.k...@gmail.comwrote: Has anyone solve this problem ?? On Fri, Mar 4, 2011 at 11:18 PM, Logic King crazy.logic.k...@gmail.comwrote: I am trying to solve the problem https://www.spoj.pl/problems/PHRASES/ but i am

[algogeeks] Re: SPOJ problem code:MAJOR

2011-03-16 Thread .bashrc
its a simple hashing problem i suppose.Beware there are some traps though.It took me 9 submissions to get it fixed. Just remember there are 1000 numbers so the array would be a[1001] -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

[algogeeks] Re: Spoj Problem : String based

2011-03-14 Thread ritu
Could you please explain ..whts the difference b/w KMP Algorithm and This problem. KMP also finds all occurrences of a string in text -- 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] Re: Spoj Problem : String based

2011-03-14 Thread Logic King
I don't Know what's KMP algorithm..i am just trying to solve this problem on my own On Tue, Mar 15, 2011 at 1:55 AM, ritu ritugarg.c...@gmail.com wrote: Could you please explain ..whts the difference b/w KMP Algorithm and This problem. KMP also finds all occurrences of a string

[algogeeks] Re: SPOJ Problem

2011-03-06 Thread Logic King
Has anyone solve this problem ?? On Fri, Mar 4, 2011 at 11:18 PM, Logic King crazy.logic.k...@gmail.comwrote: I am trying to solve the problem https://www.spoj.pl/problems/PHRASES/ but i am not getting how to approach the problem plz help me !! -- You received this message because

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-18 Thread Balaji S
just output..unicode of infinity.. :) -- 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

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-18 Thread Akash Mukherjee
hi, i have a slightly different but related probelm, i am trying to implement djiktra's in c++ how should i deal with the infinity weights( i mean does c++ have infinity)? thanx in advance :) On Fri, Feb 18, 2011 at 10:16 PM, Balaji S balaji.ceg...@gmail.com wrote: just output..unicode of

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-18 Thread Jhosimar Arias
Infinity in c++ you can use this - std::cout std::numeric_limitsdouble::infinity ()endl; But for dijkstra you can represent infinity by a long value like INT_MAX or LONG_MAX, not necesarily infinity. 2011/2/18 Akash Mukherjee akash...@gmail.com hi, i have a slightly different but related

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-18 Thread Akash Mukherjee
@jhosimar : LONG_MAX ain't working :( , LONG_MAX + 1 returns a new number ne ideas?? thanx again On Sat, Feb 19, 2011 at 9:36 AM, Jhosimar Arias jarias...@gmail.com wrote: Infinity in c++ you can use this - std::cout std::numeric_limitsdouble::infinity ()endl; But for dijkstra you can

Re: [algogeeks] Re: SPOJ problem code:MAJOR

2011-02-15 Thread Balaji Ramani
@Akshata I managed to get AC with majority algorithm. suggestions: 1) You can try to read input and find candidate in same loop 2) Use scanf and printf Thanks, Balaji. On Tue, Feb 15, 2011 at 4:30 PM, jai gupta sayhelloto...@gmail.com wrote: #includestdio.h #includestring.h

[algogeeks] Re: SPOJ problem code:MAJOR

2011-02-14 Thread Akshata Sharma
link to problem: http://www.spoj.pl/problems/MAJOR/ On Feb 14, 5:03 pm, Akshata Sharma akshatasharm...@gmail.com wrote: I am trying to submit my solution but its giving TLE. My implemetation is O(n).. and i am not able to think a faster algo than this for the problem. The problem is based on

Re: [algogeeks] Re: SPOJ problem code:MAJOR

2011-02-14 Thread sunny agrawal
try replacing cin, cout by printf,scanf On Mon, Feb 14, 2011 at 5:39 PM, Akshata Sharma akshatasharm...@gmail.comwrote: link to problem: http://www.spoj.pl/problems/MAJOR/ On Feb 14, 5:03 pm, Akshata Sharma akshatasharm...@gmail.com wrote: I am trying to submit my solution but its giving

Re: [algogeeks] Re: SPOJ problem code:MAJOR

2011-02-14 Thread Terence
Try scanf/printf instead of cin/cout. For huge data set, the IO time matters. On 2011-2-14 20:09, Akshata Sharma wrote: link to problem: http://www.spoj.pl/problems/MAJOR/ On Feb 14, 5:03 pm, Akshata Sharmaakshatasharm...@gmail.com wrote: I am trying to submit my solution but its giving TLE.

[algogeeks] Re: SPOJ problem code:MAJOR

2011-02-14 Thread sankalp srivastava
A few problems with your code : 1)Very Unclear (sorry !):- Either use a camelCase like java or use the c++ underscores style .Paste ur code on pastebin etc. 2)Too many loops :- It is O(n) , but perhaps O(4000*n) , much worse than O(n^2) in this case. 3)The problem is based on majority element

[algogeeks] Re: SPOJ problem code:MAJOR

2011-02-14 Thread NEERAJ ARORA
I simply used arrays to count the frequency of each numberMy accepted solution is: #includestdio.h int main() { int t,n,i,p,x,chk,k; int pos[1000]; int neg[1000]; int nos[100]; scanf(%d,t); while(t--) { chk=0;

Re: [algogeeks] Re: Spoj Problem : Small Factorials

2011-02-05 Thread UTKARSH SRIVASTAV
#includestdio.h long int k; void fact(long int a[],long int n) { long int c=0,temp,i=0; while(i=k) { temp=a[i]*n+c; a[i]=temp%10; c=temp/10; i++; } while(c!=0) { a[i]=c%10; c=c/10; k++; i++; } } main() {

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-04 Thread Logic King
@juver++ thanks, learned about Unicode today !! On Fri, Feb 4, 2011 at 12:48 PM, juver++ avpostni...@gmail.com wrote: It is unicode I think. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: Spoj Problem : Small Factorials

2011-02-04 Thread Rahul Verma
@jeeva Can you pls explain me in detail or some link to the tutorial of string manipulation in C++. I googled about it but most of the links are in Python Javascript. On Feb 4, 9:29 pm, subramania jeeva subramaniaje...@gmail.com wrote: Use string multiplication. :) Cheers           ~ Jeeva ~

Re: [algogeeks] Re: Spoj Problem : Small Factorials

2011-02-04 Thread abhijith reddy
http://zobayer.blogspot.com/2010/03/small-bigint-library.html On Fri, Feb 4, 2011 at 10:24 PM, Rahul Verma rahulverma@gmail.comwrote: @jeeva Can you pls explain me in detail or some link to the tutorial of string manipulation in C++. I googled about it but most of the links are in Python

[algogeeks] Re: Spoj Problem : Small Factorials

2011-02-04 Thread Dave
@Rahul: Given that 100! 100^100 = 10^200, we know that 100! has less than 200 digits. Assuming 32-bit integers, we might choose to store anywhere from 1 to 7 digits in an integer, realizing that we have to multiply the integer by a number up to 100 and still want the result to be less than 2^31.

[algogeeks] Re: Spoj Problem : Small Factorials

2011-02-04 Thread Rahul Verma
@Dave In the line t=p/100; what is the value of p here or what it means? On Feb 4, 9:57 pm, Dave dave_and_da...@juno.com wrote: @Rahul: Given that 100! 100^100 = 10^200, we know that 100! has less than 200 digits. Assuming 32-bit integers, we might choose to store anywhere from 1 to 7

[algogeeks] Re: Spoj Problem : Small Factorials

2011-02-04 Thread Dave
Oh. That is supposed to be t. So the line actually could read t /= 1; Sorry for the typo. Dave On Feb 4, 11:58 am, Rahul Verma rahulverma@gmail.com wrote: @Dave In the line t=p/100; what is the value of p here or what it means? On Feb 4, 9:57 pm, Dave

[algogeeks] Re: Spoj Problem : Small Factorials

2011-02-04 Thread Rahul Verma
Thanx to all @above. I got the result ACC. On Feb 5, 12:45 am, sunny agrawal sunny816.i...@gmail.com wrote: http://www.codechef.com/wiki/tutorial-small-factorials On Fri, Feb 4, 2011 at 11:52 PM, Dave dave_and_da...@juno.com wrote: Oh. That is supposed to be t. So the line actually

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-03 Thread juver++
std::cout ∞ std::endl; taunt -- 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] Re: SPOJ PROBLEM

2011-02-03 Thread rahul rai
does this has to do with floating point representation of numbers {IEE 754} {single precision } then the number would be like like for 32 bit field put 0 in the sign field all 1 in biased exponent field{8} and all zeros in the mantissa field{23}

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-03 Thread Logic King
@juver++ Is the sign you printed anywhere on keyboard ? how can u use it ?? i got AC althoughis there any *ALTERNATIVE SOLUTION * On Thu, Feb 3, 2011 at 8:26 PM, rahul rai raikra...@gmail.com wrote: does this has to do with floating point representation of numbers

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-03 Thread juver++
It is unicode I think. -- 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 options,

[algogeeks] Re: SPOJ PROBLEM

2011-02-02 Thread juver++
Output infinity sign :) -- 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 options,

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-02 Thread Bhavesh agrawal
sry i does not help me On Wed, Feb 2, 2011 at 10:59 PM, nishaanth nishaant...@gmail.com wrote: how about put INT_MAX ..if we add 1 there will be a overflow right ? On Wed, Feb 2, 2011 at 10:50 PM, Logic King crazy.logic.k...@gmail.comwrote: I have submitted the code of the same problem on

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-02 Thread Sreeprasad Govindankutty
in java : BigDecimal_MAX ? On Wed, Feb 2, 2011 at 10:58 PM, Bhavesh agrawal agr.bhav...@gmail.comwrote: sry i does not help me On Wed, Feb 2, 2011 at 10:59 PM, nishaanth nishaant...@gmail.com wrote: how about put INT_MAX ..if we add 1 there will be a overflow right ? On Wed, Feb 2,

[algogeeks] Re: spoj problem BOTTOM

2010-10-13 Thread Gene
The simplest approach is probably to compute the transitive closure of the graph. Then look at each pair (row k, column k) of the closure. When they're equal, k is an element of bottom. All this requires O(n^3). Since n = 5000, this should take a few seconds in the worst case. On Oct 13, 12:52 

[algogeeks] Re: Spoj problem (dynamic programming)

2010-09-08 Thread Adam
There is my version of DP: Define C(m,n) as the number of proper bracket expressions B1,B2,B3,...,Bm+n with m left brackets '(' and n right brackets ')', in which 'proper' means that for each i belonging to {1,2,...,m+n} the number of left brackets '(' in B1,B2...Bi is larger than or equal to the

Re: [algogeeks] Re: Spoj problem (dynamic programming)

2010-09-08 Thread Yan Wang
sorry, mistakes in boundaries, correct as below: if (nm) then C(m,n) = 0; for each m in {1,2...N}, C(m,1) = m; On Wed, Sep 8, 2010 at 11:22 AM, Adam wangyanadam1...@gmail.com wrote: There is my version of DP: Define C(m,n) as the number of proper bracket expressions B1,B2,B3,...,Bm+n with m

[algogeeks] Re: Spoj problem (dynamic programming)

2010-09-07 Thread soundar
post the problem link -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options,

[algogeeks] Re: Spoj problem (dynamic programming)

2010-09-07 Thread Gene
This is a nice problem. The trick is always defining the recurrence in an artful way. Here let E(L, e) be the number of bracket expressions of length L that are proper _except_ that there are e extra left brackets. So for L = 1 and 0 = e = n, we have E(1, e) = (e == 1) ? 1 : 0 That is, the