[algogeeks] Re: random number generator

2011-03-19 Thread cegprakash
@gene: can u give the function for unfair_coin_toss so that i can understand what u are doing in fair_coin_toss On Mar 19, 9:54 am, Gene wrote: > On Friday, March 18, 2011 1:47:45 PM UTC-4, Gene wrote: > > > On Mar 17, 10:24 am, saurabh agrawal wrote: > > > Given a  function which returns true 6

[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 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: Robot Moving on The Maze..Need All possible Path

2011-03-19 Thread bittu
@karans..dude..dude..dude.. 1st thing dat..a s/w engg. can't live without copy & paste..every1 does the samething so nothing new in this. . 2nd is that..whatever one is doing it should help others & understood- able.. okkk..karan..:lol well i don't like spamming but m j

[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 #include #include using namespace std; unsigned long long start,end,arr[101],arr2[101]; //number of triangles facing upwards=arr //number of triangles facing downwards=arr2 int main(){

[algogeeks] Re: Look and say sequence

2011-03-19 Thread cegprakash
do anyone got this pattern? On Mar 17, 6:16 pm, rohit wrote: > 'look and say '  (http://oeis.org/A005150) , begins 1, 11, 21, 1211, > 111221, 312211, 13112221, 1113213211 , > our task is to print this sequence. > example: > the sequence is: 1, 11 (or one 1), 21 (two 1's), 1211 (one 2, one 1), > e

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 wrote: > Here is my code for TRICOUNT problem > > //http://www.spoj.pl/problems/TRICOUNT/ > //cegprak...@gmail.com > > #include > #include > using namespace s

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

Re: [algogeeks] Re: Look and say sequence

2011-03-19 Thread Kunal Patil
Yes... See first num is 1 second is 11 (there is 1 number of 1 in previous number i.e. in 1) third is 21 (there is 2 number of 1 in previous number i.e. in 11) fourth is 1211 (there is 1 number of 2 and 1 number of 1 in previous number i.e. in 21) ans so on... Hope u got it -- You received this m

[algogeeks] Re: Look and say sequence

2011-03-19 Thread cegprakash
so the fifth number should be 1231 na?? one 2 and three 1's in 1211 y not? -- 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 algogee

Re: [algogeeks] Re: Look and say sequence

2011-03-19 Thread kunal srivastav
no .. you see from l to r one 1, one 2 and two 1. now replace one and two with 1 and 2 respec. :) so its 111221 On Sun, Mar 20, 2011 at 1:36 AM, cegprakash wrote: > so the fifth number should be 1231 na?? > one 2 and three 1's in 1211 > y not? > > -- > You received this message because you are s

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 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(){ >

[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.. #include #include 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); for(int i=

[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 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: Look and say sequence

2011-03-19 Thread cegprakash
got it!! this just takes an order of number of digits in previous number. why we need a general term? just precalculate and store in an array na -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@go

[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 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: random number generator

2011-03-19 Thread Gene
On Saturday, March 19, 2011 6:07:44 AM UTC-4, cegprakash wrote: > > @gene: can u give the function for unfair_coin_toss so that i can > understand what u are doing in fair_coin_toss > > On Mar 19, 9:54 am, Gene wrote: > > On Friday, March 18, 2011 1:47:45 PM UTC-4, Gene wrote: > > > > > On Ma

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

Re: [algogeeks] Re: Look and say sequence

2011-03-19 Thread Kunal Patil
Nopes...why precalculate and waste space...+ It gets bigger n bigger afterwards Look at this algorithm.. en.wikipedia.org/wiki/Run-length_encoding -- 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: [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] 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 wrote: > 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... >

[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] Spoj-merectcnt

2011-03-19 Thread Ankur Khurana
problem ka link bhi diya karo ya code.. On Sun, Mar 20, 2011 at 3:34 AM, sunny wrote: > hello frnds... > i am getting TLE in 12th test case .. > can anyone over ther help me to shorten it.. > #include > #include > using namespace std; > int gcd(int a, int b) > { if(b==0) >return

[algogeeks] Re: Spoj-merectcnt

2011-03-19 Thread sunny
i have given the code in the name of topic!!! its MRECTCNT btw https://www.spoj.pl/problems/MRECTCNT/ -- 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 th