[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 ema

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 wrote: > it also ran successfully on ideone.com > plz help me > i am classifying the

[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

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 wrote: > No this is f

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 wrote: > will be better if you post on spoj forums.!! > > > On Wednesday, 13 June 2012 01:40:36 UTC+5:30, gaur

[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 "Algorith

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+unsu

[algogeeks] Re: spoj problem

2012-05-13 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
hi all, i implemented the same problem with bfs but i'm getting TLE.plz tell how to reduce my running time my code is as follows... #include #include #include #include #include #include using namespace std; int main() { int i,f,s,g,u,d;//f=no. of floors,s=start,g=goal,u=up,d=down

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 On Fri,

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 wrote: > U need to check for the case when (s==g) source and destination are > same , I got stuck here , after handling this case I go

[algogeeks] Re: spoj problem

2011-11-16 Thread SAMMM
U need to check for the case when (s==g) source and destination are same , I got stuck here , after handling this case I got accepted :) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegro

[algogeeks] Re: spoj problem

2011-11-16 Thread Dave
It seems like a mathematical solution should be possible. What we want to do is find m >= 0 and n <= 0 so that m * u + n * d = g - s. Pseudocode: If (s + u > f and s - d < 1) or (f - d < g and 1 + u > g) then return "use the stairs". Use the Extended GCD algorithm (http://en.wikipedia.org/wi

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 wrote: > This input > > 100 1 5 5 91 > > Should output 20. Yours says "Take the stairs". > > 100 1 5 5 89 > > Should output 76. Y

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 #include 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

[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 wrote: > problem ishttp://www.spoj.pl/problems/ELEVTRBL/ > and my solution is give wrong answer on spoj . Plz help me to

[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 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 =  number of times to pr

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-14 Thread Don
I solved this one with a breadth-first search. Don On Nov 14, 8:27 am, Anshul AGARWAL 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. > > * > #include > ** > #include > usi

Re: [algogeeks] Re: SPOJ problem

2011-09-17 Thread amrit harry
@dave +1 On Sat, Sep 17, 2011 at 8:10 PM, Dave 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 harry wrote: > > h

[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 wrote: > http://www.spoj.pl/problems/POUR1/ > hw the 2nd given test is correct. >

[algogeeks] Re: SPOJ Problem DP

2011-07-02 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 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 ? > > PS : Don'

[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 algogeeks+unsu

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, shady

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 . wrote: > 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, answ

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 wrote: > O.K can anyone suggest the combinatorial solution.I thought it this way- > Assume k chair

Re: [algogeeks] Re: spoj problem chairs

2011-06-20 Thread saurabh singh
O.K can anyone suggest the combinatorial solution.I thought it this way- Assume k chairs as one chair.Now no. of ways arranging these chairs would be ((n-k+1)-1)! and the number of ways of arranging the k chairs would be k!. So the no. of ways of arranging the chairs so that they are always togethe

[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 wrote: > @above   Better you ask it on spoj forum > > On Sun, Jun 19, 2011 at 7:27 PM, saurabh singh wrote: > > I am getting WA for this problem.I dont kno

[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 wrote: > 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 >

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 On Mon, Mar 21, 2011 at 5:50 PM, cegprakash wrote: > hello... someone plz tell me how to arrive @ that formula..

Re: [algogeeks] Re: Spoj Problem Help

2011-05-24 Thread sravanreddy001
@logic king.. the matrix exponentiation methos is something similar to the exponentiation algorithm where x^n = x^n/2 * x*n/2 when n is even x^(n-1)/2 * x^(n-1)/2 * x when x = odd so in this way.. to calculate the x^63 value.. you need not multiply x 62 times.. but.. x^32, x^16, x^

Re: [algogeeks] Re: Spoj Problem Help

2011-05-24 Thread Aakash Johari
I have already given a link in this thread for Zobayer's blog. That has the explanation for doing Matrix expo. If something is not clear there, you can ask. http://zobayer.blogspot.com/2010/11/matrix-exponentiation.html On Tue, May 24, 2011 at 1:42 AM, Logic King wrote: > @aakash > the cases ar

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 wrote: > It's done. Today I tried it. > > Simply for N=0 and N=1 answer is (0,0) = 0 and (1,1)=2 respectively. > >

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, May

Re: [algogeeks] Re: Spoj Problem Help

2011-05-23 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 --> 32244629420445529739893461909967209390964997649909

Re: [algogeeks] Re: Spoj Problem Help

2011-05-23 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 wrote: > @Dave: nice idea.. ll this give AC ? > > -- > You received this message because you are

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 m

[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

[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++) {

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 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 post to this group,

Re: [algogeeks] Re: SPOJ problem

2011-03-31 Thread saurabh singh
Sorry for ignorance but i didnt got what *1d* means in the formula On Tue, Mar 29, 2011 at 5:54 PM, КоЦіК wrote: > 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 : 1

[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 : 105

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 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 somewhere and traver

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 sukhmeet singh
is there a better solution than O(n) ??? any datastructure possible On Wed, Mar 23, 2011 at 8:20 PM, .bashrc 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 wrote: > > i m getting TLE for this soln and m not g

[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 wrote: > I am very sorry but i dont think i got your point.You suggesting > interpol

[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 wrote: > i m getting TLE for this soln and m not getting the concept used in > the above soln can anyone help?? > #include > using namespace std; > int main() > { >     int t,n,k

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 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 forum also. > > > On

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 wrote: > but..i read this oly after my senior taught me se

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 wrote: > i found this good.. > > http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=lowestCommonAncestor > > > > On Mon, Mar 21, 2011 at 6:02 PM, Anurag atri wrote: > >> yes , plea

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-23 Thread bharath kannan
i found this good.. http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=lowestCommonAncestor On Mon, Mar 21, 2011 at 6:02 PM, Anurag atri wrote: > yes , please suggest a nice tutorial for segment trees .. > > > On Mon, Mar 21, 2011 at 5:48 PM, cegprakash wrote: > >> hey i want to learn seg

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 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 subscribed to

[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 algogeeks+unsubscr...@

[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 unsubscrib

[algogeeks] Re: SPOJ problem- TRICOUNT

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

Re: [algogeeks] Re: SPOJ problem-BRCKTS

2011-03-19 Thread bharath kannan
http://www.spoj.pl/forum/viewtopic.php?f=3&t=5240&p=20667&hilit=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

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 th

[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 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 to this group, send e

[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+unsubscr...@google

[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+unsubsc

[algogeeks] Re: SPOJ problem- TRICOUNT

2011-03-19 Thread cegprakash
how did u arrive at 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 algogeeks+unsubscr...@googlegroups.com. For more

[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 wrote: > i've modified my algorithm > but i'm getting wrong answer. someone help.. > > #include > using namespace std; > unsigned long long start,end,arr[101],arr2[101]; > int main(){ >

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. can

[algogeeks] Re: SPOJ problem- TRICOUNT

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

[algogeeks] Re: SPOJ Problem : PRIME1

2011-03-19 Thread Dennisbot
why not use the criba of Eratóstenes? On 18 mar, 11:41, samby 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 in a single line >

[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

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?? #include 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};

[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

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 wrote: > Has anyone solve this problem ?? > > > On Fri, Mar 4, 2011 at 11:18 PM, Logic King wrote: > >> I am trying to solve the problem https://www.spoj.pl/problems/PHRASES/ >> >> but i am not getting how to approach the problem

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 wrote: > 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 r

[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 algogeeks@googlegroups

[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 wrote: > 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 you are subscribed to t

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 wrote: > Infinity in c++ you can use this -> std::cout << > std::numeric_limits::infinity ()< But for dijkstra you can represent infinity by a long va

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-18 Thread Jhosimar Arias
Infinity in c++ you can use this -> std::cout << std::numeric_limits::infinity ()< > 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 :) > > >

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 wrote: > just output..unicode of infinity.. :) > > -- > Y

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 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 wrote: > #include > #include > #include > void work() { > int n,max,maxpos,x,

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

2011-02-15 Thread jai gupta
#include #include #include void work() { int n,max,maxpos,x,i; scanf("%d",&n); int *arr=(int*) malloc(sizeof(int)*2005); memset(arr,0,2005); max=maxpos=0; for(i=0;imax) { max=arr[x+1000]; maxpos=x; } } if(max>n/2) print

[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: #include 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;

[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 con

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 Sharma wrote: I am trying to submit my solution but its giving TLE. My implemetation is O(n).

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 wrote: > link to problem: http://www.spoj.pl/problems/MAJOR/ > > On Feb 14, 5:03 pm, Akshata Sharma wrote: > > I am trying to submit my solution but its giving TLE. My implemetation is > > O(n).. and i am not

[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 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 finding the majority ele

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

2011-02-05 Thread UTKARSH SRIVASTAV
#include 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() { lon

[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 wrote: > http://www.codechef.com/wiki/tutorial-small-factorials > > > > > > > > > > On Fri, Feb 4, 2011 at 11:52 PM, Dave wrote: > > Oh. That is supposed to be t. So the line actually could read > >        t /= 1;

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

2011-02-04 Thread sunny agrawal
http://www.codechef.com/wiki/tutorial-small-factorials On Fri, Feb 4, 2011 at 11:52 PM, Dave wrote: > 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 wrote: > > @Dave > > In the line t=p/10

[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 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 wrote: > > > > > @Rahul: Given that 10

[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 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 digits in an integer, r

[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.

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 wrote: > @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

[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 wrote: > Use string multiplication. :) > > Cheers >           ~ Jeeva ~ > > On Fri, Feb 4, 2

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++ 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@googlegroups.com

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, v

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 wrote: > > does this has to do with floating point representation of numbers {IEE 754} > {single

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} http://en.wikipedia.org/wiki/Single_precision_floa

Re: [algogeeks] Re: SPOJ PROBLEM

2011-02-03 Thread sourabh jakhar
can u give the answer On Thu, Feb 3, 2011 at 8:11 PM, Balaji S wrote: > i got 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 fro

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 m

  1   2   >