Re: [algogeeks] Array problem

2011-05-22 Thread Azazle simon
@ps: ..:-)

On 5/22/11, Piyush Sinha  wrote:
> @MONSIEUR..
> someone once said"THE SECRET OF SUCCESS IS TO NEVER REVEAL YOUR
> SOURCES..." ;)...:P..:P
>
> On 5/22/11, MONSIEUR  wrote:
>> @piyush: excellent buddybtw what was the initial
>> spark...???.:-)
>>
>> On May 21, 1:01 pm, Piyush Sinha  wrote:
>>> @Amit JaspalThe algo given by me works for the given case..check
>>> it
>>>
>>> On 5/20/11, Anurag Bhatia  wrote:
>>>
>>>
>>>
>>> > Just need some clarification; sorry I joined the thread late. What are
>>> > we
>>> > trying maximize? A[j] -A[i] such that i>>
>>> > --Anurag
>>>
>>> > On Fri, May 20, 2011 at 12:34 AM, Kunal Patil 
>>> > wrote:
>>>
>>> >> @ Piyush: Excellent Solution...It appears both Correct and O(n)...Good
>>> >> work !![?]
>>>
>>> >> Just a minor correction in your algo.[?]
>>>
>>> >> while(B[i]>> >>  j++;
>>> >> must also check for J's bound as:
>>> >> while ( j < ( sizeof(A)/sizeof(A[0]) ) && B[i]>> >>  j++;
>>> >> Or it will crash when J goes out of bound and we try to reference
>>> >> C[j].
>>>
>>> >> Nywayz..thnx for the solution and algo !!
>>>
>>> >> --
>>> >> 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, visit this group at
>>> >>http://groups.google.com/group/algogeeks?hl=en.
>>>
>>> > --
>>> > 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, visit this group at
>>> >http://groups.google.com/group/algogeeks?hl=en.
>>>
>>> --
>>> *Piyush Sinha*
>>> *IIIT, Allahabad*
>>> *+91-8792136657*
>>> *+91-7483122727*
>>> *https://www.facebook.com/profile.php?id=10655377926*
>>>
>>>  363.gif
>>> < 1KViewDownload
>>>
>>>  360.gif
>>> < 1KViewDownload
>>
>> --
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> *Piyush Sinha*
> *IIIT, Allahabad*
> *+91-8792136657*
> *+91-7483122727*
> *https://www.facebook.com/profile.php?id=10655377926 *
>
> --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
Sent from my mobile device

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Aakash Johari
A modification in the above code,

int divide(int a, int b)
> {
> int temp = 0;
> int result = 0;
> int mask, i;
>
> printf ("a = %d, b = %d\n", a, b);
>
> temp = 0;
>
> for ( i = 30; i >= 0; i-- ) {
> mask = 1 << i;
>
> temp <<= 1;
>
> temp |= ((a & mask) >> i) & 1;
>
> result <<= 1;
>
> if ( temp >= b ) {
> result |= 1;
> temp -= b;
> }
> }
>
> return result;
> }
>
>
> On Sun, May 22, 2011 at 10:56 PM, Aakash Johari wrote:

> Try the following code: One can more optimize it.
>
>
>> int divide(int a, int b)
>> {
>> int temp = 0;
>> int result = 0;
>> int mask, i;
>>
>> printf ("a = %d, b = %d\n", a, b);
>>
>> temp = 0;
>>
>> for ( i = 30; i >= 0; i-- ) {
>> mask = 1 << i;
>>
>> temp <<= 1;
>>
>> temp |= ((a & mask) >> i) & 1;
>>
>> result <<= 1;
>>
>> if ( temp >= b ) {
>> result |= 1;
>> temp ^= b;
>> }
>> }
>>
>> return result;
>> }
>>
>>
>
> On Sun, May 22, 2011 at 10:29 PM, Aakash Johari wrote:
>
>> try for 15 and 3
>>
>>
>> On Sun, May 22, 2011 at 10:22 PM, D.N.Vishwakarma@IITR > > wrote:
>>
>>> a divide b
>>>
>>> while(b!=1){
>>>  a >>=1;
>>>  b >>=1;
>>> }
>>>
>>> printf("%d\n",a);
>>>
>>> On 5/22/11, Wladimir Tavares  wrote:
>>> > a divide b
>>> >
>>> > while(b!=1){
>>> >   a <<=1;
>>> >   b <<=1;
>>> > }
>>> >
>>> > printf("%d\n",a);
>>> > Wladimir Araujo Tavares
>>> > *Federal University of Ceará
>>> >
>>> > *
>>> >
>>> >
>>> >
>>> >
>>> > On Sun, May 22, 2011 at 1:33 PM, Prakash D IT @ CEG
>>> > wrote:
>>> >
>>> >> could someone explain the algo with an example?
>>> >>
>>> >>
>>> >> On Sun, May 22, 2011 at 8:21 PM, Puneet Ginoria
>>> >> wrote:
>>> >>
>>> >>> thnxx all.. i got the soln..
>>> >>> Qdumanshu: i was asking for quotient and remainder when we divide 2
>>> nos.
>>> >>> without actually dividing them...
>>> >>>
>>> >>>
>>> 
>>> >>>  --
>>> >>> 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, visit this group at
>>> >>> http://groups.google.com/group/algogeeks?hl=en.
>>> >>>
>>> >>
>>> >>  --
>>> >> 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, visit this group at
>>> >> http://groups.google.com/group/algogeeks?hl=en.
>>> >>
>>> >
>>> > --
>>> > 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, visit this group at
>>> > http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> >
>>>
>>>
>>> --
>>> **With Regards
>>> Deoki Nandan Vishwakarma
>>> IITR MCA
>>> Mathematics Department*
>>> *
>>>
>>> --
>>> 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, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> -Aakash Johari
>> (IIIT Allahabad)
>>
>>
>>
>>
>>
>
>
> --
> -Aakash Johari
> (IIIT Allahabad)
>
>
>
>
>


-- 
-Aakash Johari
(IIIT 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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Aakash Johari
Try the following code: One can more optimize it.


> int divide(int a, int b)
> {
> int temp = 0;
> int result = 0;
> int mask, i;
>
> printf ("a = %d, b = %d\n", a, b);
>
> temp = 0;
>
> for ( i = 30; i >= 0; i-- ) {
> mask = 1 << i;
>
> temp <<= 1;
>
> temp |= ((a & mask) >> i) & 1;
>
> result <<= 1;
>
> if ( temp >= b ) {
> result |= 1;
> temp ^= b;
> }
> }
>
> return result;
> }
>
>

On Sun, May 22, 2011 at 10:29 PM, Aakash Johari wrote:

> try for 15 and 3
>
>
> On Sun, May 22, 2011 at 10:22 PM, D.N.Vishwakarma@IITR 
> wrote:
>
>> a divide b
>>
>> while(b!=1){
>>  a >>=1;
>>  b >>=1;
>> }
>>
>> printf("%d\n",a);
>>
>> On 5/22/11, Wladimir Tavares  wrote:
>> > a divide b
>> >
>> > while(b!=1){
>> >   a <<=1;
>> >   b <<=1;
>> > }
>> >
>> > printf("%d\n",a);
>> > Wladimir Araujo Tavares
>> > *Federal University of Ceará
>> >
>> > *
>> >
>> >
>> >
>> >
>> > On Sun, May 22, 2011 at 1:33 PM, Prakash D IT @ CEG
>> > wrote:
>> >
>> >> could someone explain the algo with an example?
>> >>
>> >>
>> >> On Sun, May 22, 2011 at 8:21 PM, Puneet Ginoria
>> >> wrote:
>> >>
>> >>> thnxx all.. i got the soln..
>> >>> Qdumanshu: i was asking for quotient and remainder when we divide 2
>> nos.
>> >>> without actually dividing them...
>> >>>
>> >>>
>> 
>> >>>  --
>> >>> 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, visit this group at
>> >>> http://groups.google.com/group/algogeeks?hl=en.
>> >>>
>> >>
>> >>  --
>> >> 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, visit this group at
>> >> http://groups.google.com/group/algogeeks?hl=en.
>> >>
>> >
>> > --
>> > 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, visit this group at
>> > http://groups.google.com/group/algogeeks?hl=en.
>> >
>> >
>>
>>
>> --
>> **With Regards
>> Deoki Nandan Vishwakarma
>> IITR MCA
>> Mathematics Department*
>> *
>>
>> --
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> -Aakash Johari
> (IIIT Allahabad)
>
>
>
>
>


-- 
-Aakash Johari
(IIIT 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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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

> 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  wrote:
>
>> Try thinking backwards.
>> (0,1),(1,2),(2,3),(3,5),(5,8),(8,13),...
>>
>> 2011/5/22 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
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>> >
>> >
>>
>>
>>
>> --
>> __
>>
>> --
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
-Aakash Johari
(IIIT 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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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

> Try thinking backwards.
> (0,1),(1,2),(2,3),(3,5),(5,8),(8,13),...
>
> 2011/5/22 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 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
>
>
> --
> __
>
> --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Aakash Johari
try for 15 and 3

On Sun, May 22, 2011 at 10:22 PM, D.N.Vishwakarma@IITR wrote:

> a divide b
>
> while(b!=1){
>  a >>=1;
>  b >>=1;
> }
>
> printf("%d\n",a);
>
> On 5/22/11, Wladimir Tavares  wrote:
> > a divide b
> >
> > while(b!=1){
> >   a <<=1;
> >   b <<=1;
> > }
> >
> > printf("%d\n",a);
> > Wladimir Araujo Tavares
> > *Federal University of Ceará
> >
> > *
> >
> >
> >
> >
> > On Sun, May 22, 2011 at 1:33 PM, Prakash D IT @ CEG
> > wrote:
> >
> >> could someone explain the algo with an example?
> >>
> >>
> >> On Sun, May 22, 2011 at 8:21 PM, Puneet Ginoria
> >> wrote:
> >>
> >>> thnxx all.. i got the soln..
> >>> Qdumanshu: i was asking for quotient and remainder when we divide 2
> nos.
> >>> without actually dividing them...
> >>>
> >>>
> 
> >>>  --
> >>> 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, visit this group at
> >>> http://groups.google.com/group/algogeeks?hl=en.
> >>>
> >>
> >>  --
> >> 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, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >
> > --
> > 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, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
>
> --
> **With Regards
> Deoki Nandan Vishwakarma
> IITR MCA
> Mathematics Department*
> *
>
> --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
-Aakash Johari
(IIIT 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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread D.N.Vishwakarma@IITR
a divide b

while(b!=1){
  a >>=1;
  b >>=1;
}

printf("%d\n",a);

On 5/22/11, Wladimir Tavares  wrote:
> a divide b
>
> while(b!=1){
>   a <<=1;
>   b <<=1;
> }
>
> printf("%d\n",a);
> Wladimir Araujo Tavares
> *Federal University of Ceará
>
> *
>
>
>
>
> On Sun, May 22, 2011 at 1:33 PM, Prakash D IT @ CEG
> wrote:
>
>> could someone explain the algo with an example?
>>
>>
>> On Sun, May 22, 2011 at 8:21 PM, Puneet Ginoria
>> wrote:
>>
>>> thnxx all.. i got the soln..
>>> Qdumanshu: i was asking for quotient and remainder when we divide 2 nos.
>>> without actually dividing them...
>>>
>>>

>>>  --
>>> 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, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
**With Regards
Deoki Nandan Vishwakarma
IITR MCA
Mathematics Department*
*

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: PUZZLE

2011-05-22 Thread Wladimir Tavares
Brute-force algorithm with memoization for this problem!

/*
Autor: Wladimir Araújo Tavares
*/
#include 
#include 
#include 
#include 
#define min(a,b) ab?a:b
int memo[3001][1001];
int banana(int V, int D){
int total;
int j;
int temp;
if(V < D) return 0;
if(memo[V][D]!=-1) return memo[V][D];
//one travel
if(V>1000)
total = 1000 - D;
else
  total = V-D;
//more than one
if(V>1000){
temp = banana(V-1000, D) + 1000-2*D;
}else{
temp = V-D;
}
total = max(total, temp);
//cache
for(j=1;j total)
  total = temp;
}
memo[V][D] = total;
return total;

}
int main(){
int x,i,j;
for(i=1;i<=3000;i++)
  for(j=1;j<=1000;j++)
memo[i][j] = -1;
while(1){
scanf("%d",&x);
printf("%d\n",banana(3000,x));
}
  return 0;
}



Wladimir Araujo Tavares
*Federal University of Ceará

*

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: PUZZLE

2011-05-22 Thread Wladimir Tavares
@ Dave: Disregard what I wrote!!


The algorithm that I developed after works as follows:
We can recursively define the maximum number of bananas brought by the
elephant by D km starting with V bananas:

banana (V, D) = max (V-D,
 banana (V - min (V, 1000), D) + min (V,
1000) -2 * D)
 banana (banana (V, j), D-j), 1 <= j  wrote:

> @Wladimir: I don't understand what you are saying. If the first cache
> of bananas is established x km from the starting spot, with x <= 500,
> the elephant can deliver 3,000 - 5*x bananas to that cache. In your
> case, x = 250, so the elephant can deliver 1,750 bananas.
>
> Dave
>
> On May 20, 11:56 pm, Wladimir Tavares  wrote:
> > Consider the following scenario:
> > On the first trip, the elephant carries 1000 bananas. the elephant walk
> 250
> > km consuming 250 bananas  left in position 250 (500 bananas). After that,
> he
> > goes back over 250 Km eating more bananas 250 bananas. On the second
> trip,
> > the elephant carries 1000 bananas again, walk 250 km, carrying over 250
> > bananas and arrives at B with 250 bananas. More he can not go back just
> > because  finish bananas.
> > ok?
> > Wladimir Araujo Tavares
> > *Federal University of Ceará
> >
> > *
> >
> >
> >
> > On Sat, May 21, 2011 at 1:27 AM, Dave  wrote:
> > > @Wladimir: According to the problem statement, the elephant starts out
> > > with 3,000 bananas. I am saying that the elephant can deliver 534
> > > bananas to the destination 1,000 km away.
> >
> > > Dave
> >
> > > On May 20, 7:22 pm, Wladimir Tavares  wrote:
> > > > with 534 , the elephant can travel only 534 Km! I am right?
> > > > Wladimir Araujo Tavares
> > > > *Federal University of Ceará
> >
> > > > *
> >
> > > > On Fri, May 20, 2011 at 8:36 PM, Dave 
> wrote:
> > > > > Upon reading the problem more carefully, the answer is 534 bananas,
> > > > > not 533-1/3.
> >
> > > > > Dave
> >
> > > > > On May 20, 3:43 pm, Dave  wrote:
> > > > > > @Bhavesh: 533-1/3.
> >
> > > > > > Dave
> >
> > > > > > On May 20, 10:47 am, Bhavesh agrawal 
> wrote:
> >
> > > > > > > 1 elephant can take 1000 banana at a time and eat 1 banana
> after
> > > each
> > > > > 1km
> > > > > > > travel.
> > > > > > > total bananas are 3000 and distance have to travel from A to B
> is
> > > > > 1000km.
> >
> > > > > > > So how many max bananas he can take from A to B.   (he'll eat
> in
> > > return
> > > > > > > travel  too)- Hide quoted text -
> >
> > > > > > - Show quoted 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.com.
> > > > > To unsubscribe from this group, send email to
> > > > > algogeeks+unsubscr...@googlegroups.com.
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text -
> >
> > > > - Show quoted 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.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
> >
> > - Show quoted 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.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Wladimir Tavares
a divide b

while(b!=1){
  a <<=1;
  b <<=1;
}

printf("%d\n",a);
Wladimir Araujo Tavares
*Federal University of Ceará

*




On Sun, May 22, 2011 at 1:33 PM, Prakash D IT @ CEG wrote:

> could someone explain the algo with an example?
>
>
> On Sun, May 22, 2011 at 8:21 PM, Puneet Ginoria 
> wrote:
>
>> thnxx all.. i got the soln..
>> Qdumanshu: i was asking for quotient and remainder when we divide 2 nos.
>> without actually dividing them...
>>
>>
>>>
>>  --
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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 :
> 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 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, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>



-- 
__

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Dave
@Prakash: Think long division in binary.

Dave

On May 22, 11:33 am, "Prakash D IT @ CEG" 
wrote:
> could someone explain the algo with an example?
>
> On Sun, May 22, 2011 at 8:21 PM, Puneet Ginoria 
> wrote:
>
>
>
> > thnxx all.. i got the soln..
> > Qdumanshu: i was asking for quotient and remainder when we divide 2 nos.
> > without actually dividing them...
>
> >  --
> > 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, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>
> - Show quoted 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.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: PUZZLE

2011-05-22 Thread Dave
@Wladimir: I don't understand what you are saying. If the first cache
of bananas is established x km from the starting spot, with x <= 500,
the elephant can deliver 3,000 - 5*x bananas to that cache. In your
case, x = 250, so the elephant can deliver 1,750 bananas.

Dave

On May 20, 11:56 pm, Wladimir Tavares  wrote:
> Consider the following scenario:
> On the first trip, the elephant carries 1000 bananas. the elephant walk 250
> km consuming 250 bananas  left in position 250 (500 bananas). After that, he
> goes back over 250 Km eating more bananas 250 bananas. On the second trip,
> the elephant carries 1000 bananas again, walk 250 km, carrying over 250
> bananas and arrives at B with 250 bananas. More he can not go back just
> because  finish bananas.
> ok?
> Wladimir Araujo Tavares
> *Federal University of Ceará
>
> *
>
>
>
> On Sat, May 21, 2011 at 1:27 AM, Dave  wrote:
> > @Wladimir: According to the problem statement, the elephant starts out
> > with 3,000 bananas. I am saying that the elephant can deliver 534
> > bananas to the destination 1,000 km away.
>
> > Dave
>
> > On May 20, 7:22 pm, Wladimir Tavares  wrote:
> > > with 534 , the elephant can travel only 534 Km! I am right?
> > > Wladimir Araujo Tavares
> > > *Federal University of Ceará
>
> > > *
>
> > > On Fri, May 20, 2011 at 8:36 PM, Dave  wrote:
> > > > Upon reading the problem more carefully, the answer is 534 bananas,
> > > > not 533-1/3.
>
> > > > Dave
>
> > > > On May 20, 3:43 pm, Dave  wrote:
> > > > > @Bhavesh: 533-1/3.
>
> > > > > Dave
>
> > > > > On May 20, 10:47 am, Bhavesh agrawal  wrote:
>
> > > > > > 1 elephant can take 1000 banana at a time and eat 1 banana after
> > each
> > > > 1km
> > > > > > travel.
> > > > > > total bananas are 3000 and distance have to travel from A to B is
> > > > 1000km.
>
> > > > > > So how many max bananas he can take from A to B.   (he'll eat in
> > return
> > > > > > travel  too)- Hide quoted text -
>
> > > > > - Show quoted 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.com.
> > > > To unsubscribe from this group, send email to
> > > > algogeeks+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text -
>
> > > - Show quoted 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.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>
> - Show quoted 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.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Array problem

2011-05-22 Thread Piyush Sinha
@MONSIEUR..
someone once said"THE SECRET OF SUCCESS IS TO NEVER REVEAL YOUR
SOURCES..." ;)...:P..:P

On 5/22/11, MONSIEUR  wrote:
> @piyush: excellent buddybtw what was the initial
> spark...???.:-)
>
> On May 21, 1:01 pm, Piyush Sinha  wrote:
>> @Amit JaspalThe algo given by me works for the given case..check
>> it
>>
>> On 5/20/11, Anurag Bhatia  wrote:
>>
>>
>>
>> > Just need some clarification; sorry I joined the thread late. What are
>> > we
>> > trying maximize? A[j] -A[i] such that i>
>> > --Anurag
>>
>> > On Fri, May 20, 2011 at 12:34 AM, Kunal Patil 
>> > wrote:
>>
>> >> @ Piyush: Excellent Solution...It appears both Correct and O(n)...Good
>> >> work !![?]
>>
>> >> Just a minor correction in your algo.[?]
>>
>> >> while(B[i]> >>  j++;
>> >> must also check for J's bound as:
>> >> while ( j < ( sizeof(A)/sizeof(A[0]) ) && B[i]> >>  j++;
>> >> Or it will crash when J goes out of bound and we try to reference C[j].
>>
>> >> Nywayz..thnx for the solution and algo !!
>>
>> >> --
>> >> 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, visit this group at
>> >>http://groups.google.com/group/algogeeks?hl=en.
>>
>> > --
>> > 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, visit this group at
>> >http://groups.google.com/group/algogeeks?hl=en.
>>
>> --
>> *Piyush Sinha*
>> *IIIT, Allahabad*
>> *+91-8792136657*
>> *+91-7483122727*
>> *https://www.facebook.com/profile.php?id=10655377926*
>>
>>  363.gif
>> < 1KViewDownload
>>
>>  360.gif
>> < 1KViewDownload
>
> --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
*Piyush Sinha*
*IIIT, Allahabad*
*+91-8792136657*
*+91-7483122727*
*https://www.facebook.com/profile.php?id=10655377926 *

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Prakash D IT @ CEG
could someone explain the algo with an example?

On Sun, May 22, 2011 at 8:21 PM, Puneet Ginoria wrote:

> thnxx all.. i got the soln..
> Qdumanshu: i was asking for quotient and remainder when we divide 2 nos.
> without actually dividing them...
>
>
>>
>  --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Puneet Ginoria
thnxx all.. i got the soln..
Qdumanshu: i was asking for quotient and remainder when we divide 2 nos.
without actually dividing them...


>

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread Dumanshu
Could u plz elaborate? about the quotient??

On May 22, 1:50 pm, ankit sambyal  wrote:
> Solve it using shift operator   here is the crude algo :
>  the procedure for the division algorithm, given a dividend and a divisor
> would be to left shift (multiply by 2) the divisor till it reaches
> dividend/2, then continue this routine with the the difference between the
> dividend and divisor and divisor till the point where dividend is less than
> divisor or their difference is zero.
>
>
>
>
>
>
>
> On Sun, May 22, 2011 at 1:22 AM, kunzmilan  wrote:
>
> > On 22 kvě, 08:40, punnu  wrote:
> > > Given 2 nos.  we need to divide them without performing divison.
> > > Please give a better solution than subtracting the nos. again and
> > > again.
> > > Try to multiply the smaler number and by a suitable number, subtract the
> > product, compare, and repeat adding zeroes, if necessary.
> > kunzmilan
>
> > --
> > 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, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: PUZZLE

2011-05-22 Thread Wladimir Tavares
Consider the following scenario:
On the first trip, the elephant carries 1000 bananas. the elephant walk 250
km consuming 250 bananas  left in position 250 (500 bananas). After that, he
goes back over 250 Km eating more bananas 250 bananas. On the second trip,
the elephant carries 1000 bananas again, walk 250 km, carrying over 250
bananas and arrives at B with 250 bananas. More he can not go back just
because  finish bananas.
ok?
Wladimir Araujo Tavares
*Federal University of Ceará

*




On Sat, May 21, 2011 at 1:27 AM, Dave  wrote:

> @Wladimir: According to the problem statement, the elephant starts out
> with 3,000 bananas. I am saying that the elephant can deliver 534
> bananas to the destination 1,000 km away.
>
> Dave
>
> On May 20, 7:22 pm, Wladimir Tavares  wrote:
> > with 534 , the elephant can travel only 534 Km! I am right?
> > Wladimir Araujo Tavares
> > *Federal University of Ceará
> >
> > *
> >
> >
> >
> > On Fri, May 20, 2011 at 8:36 PM, Dave  wrote:
> > > Upon reading the problem more carefully, the answer is 534 bananas,
> > > not 533-1/3.
> >
> > > Dave
> >
> > > On May 20, 3:43 pm, Dave  wrote:
> > > > @Bhavesh: 533-1/3.
> >
> > > > Dave
> >
> > > > On May 20, 10:47 am, Bhavesh agrawal  wrote:
> >
> > > > > 1 elephant can take 1000 banana at a time and eat 1 banana after
> each
> > > 1km
> > > > > travel.
> > > > > total bananas are 3000 and distance have to travel from A to B is
> > > 1000km.
> >
> > > > > So how many max bananas he can take from A to B.   (he'll eat in
> return
> > > > > travel  too)- Hide quoted text -
> >
> > > > - Show quoted 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.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
> >
> > - Show quoted 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.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: C aps output

2011-05-22 Thread siva viknesh
thanks for all for clearing my doubt :)

On Sat, May 21, 2011 at 12:07 AM, Selvakumar N
wrote:

> Two byte rep :
> 256(0001) + 1(0001)
>
> iPtr points to least significant byte , iPtr + 1 points to most significant
> byte
>
> P.S : Not verified by code
> -Selva
>
> On Fri, May 20, 2011 at 8:49 PM, siva viknesh wrote:
>
>>
>> main()
>> {
>> int i = 257;
>> int *iPtr = &i;
>> printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
>> }
>> Answer:
>> 1 1
>>
>>
>> main()
>> {
>> int i = 258;
>> int *iPtr = &i;
>> printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
>> }
>> Answer:
>> 2 1
>>
>>
>>
>> ..can anybody explain how??
>> --
>> Regards,
>> $iva
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "ACM Anna University" group.
>> To post to this group, send an email to acm...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> acm_au+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/acm_au?hl=en-GB.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "ACM Anna University" group.
> To post to this group, send an email to acm...@googlegroups.com.
> To unsubscribe from this group, send email to
> acm_au+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/acm_au?hl=en-GB.
>



-- 
Regards,
$iva

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: c aps ..output discrepancy !!!

2011-05-22 Thread siva viknesh
hi anybody reply please!!

On May 20, 6:53 pm, siva viknesh  wrote:
> hi
>
> #include
> main()
> {
> int a=2,*f1,*f2;
> f1=f2=&a;
> *f2+=*f2+=a+=2.5;
> printf("\n%d %d %d",a,*f1,*f2);
>
> }
>
> for this code in code blocks IDE got 8 8 8 as op
>
>                          inhttp://ideone.com/ok850got 12 12 12
>
>                        in 175 c aps pdf it has been given as 16 16 16 as
> output 
>
> so this code also has something to do with SEQUENCE POINTS 
>
> is sequence points applicable for pointers too ??
>
> the output varies based on compiler or underlying machine architecture
>
> can anybody give clear picture about sequence points and whats happening in
> this code...thanks in advance :)
>
> --
> Regards,
> $iva

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[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 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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: C OUTPUT

2011-05-22 Thread Nishant
conversion frm int to float and float to int is very poor in case of
printf funtion
so when we give the input to t then that value is displayed for all
the printf function
since %f modifier doesn't accept x (int) as
a successful argument so it takes the
latest float value..


On May 22, 2:41 pm, sourabh jakhar  wrote:
> #include
> void main()
> {
>     long x;
>     float t;
>     scanf("%f",&t);
>     printf("%d\n",t);
>     x=90;
>     printf("%f\n",x);
>     {
>         x=1;
>         printf("%f\n",x);
>         {
>             x=30;
>             printf("%f\n",x);
>         }
>         printf("%f\n",x);
>     }
>         x==9;
>         printf("%f\n",x);
>
> }
>
> CAN ANYBODY EXPLAIN THE OUTPUT
>
> --
> SOURABH JAKHAR,(CSE)(3 year)
> ROOM NO 167 ,
> TILAK,HOSTEL
> 'MNNIT ALLAHABAD
>
> The Law of Win says, "Let's not do it your way or my way; let's do it the
> best way."

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Kingdom Of MapleWood

2011-05-22 Thread immanuel kingston
Since the number of islands is even, either the sum of areas of islands in
the even position have a greater area or the ones in the odd position have
greater area.

Eric can start from the 1st island if the sum of areas of the islands at the
odd position is greater than that of even ones.or can start from the nth
island(since n is even) if the sum of areas of the islands at the even
position is greater than that of odd ones.

Following the same approach he can get a larger area than Finn for sure.
This approach will always ensure that Eric ends up getting the larger area
but may not be the optimal solution.

Thanks,
Immanuel

On Tue, May 3, 2011 at 7:28 AM, abhishekriyer wrote:

> Kingdom of Maplewood is a beautiful country comprising of a lot of
> small islands of different areas. All the islands are in a straight
> row. King Rosewood is getting old and has decided to divide the
> islands among his two sons - Eric and Finn. Luckily, the total number
> of islands is even. He has also decided a few rules for the division
> of islands:
>
> i) Eric and Finn will be given alternate turns to choose the islands
> ii) They can only choose one island at a time from either the
> beginning or the end of the row of islands.
> iii) Once an island is chosen by someone,it cannot be chosen by other
> person.
> Suppose you are Eric and you are given the first choice. Find out the
> maximum area you are sure you can pick.
>
>
> I dont want the solution but the logic of doing this ... I googled and
> understood its a DP problem but was unable to proceed further. Any
> help is appreciated ...
>
> --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] C OUTPUT

2011-05-22 Thread sourabh jakhar
#include
void main()
{
long x;
float t;
scanf("%f",&t);
printf("%d\n",t);
x=90;
printf("%f\n",x);
{
x=1;
printf("%f\n",x);
{
x=30;
printf("%f\n",x);
}
printf("%f\n",x);
}
x==9;
printf("%f\n",x);

}


CAN ANYBODY EXPLAIN THE OUTPUT

-- 
SOURABH JAKHAR,(CSE)(3 year)
ROOM NO 167 ,
TILAK,HOSTEL
'MNNIT ALLAHABAD

The Law of Win says, "Let's not do it your way or my way; let's do it the
best way."

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread ankit sambyal
Solve it using shift operator   here is the crude algo :
 the procedure for the division algorithm, given a dividend and a divisor
would be to left shift (multiply by 2) the divisor till it reaches
dividend/2, then continue this routine with the the difference between the
dividend and divisor and divisor till the point where dividend is less than
divisor or their difference is zero.

On Sun, May 22, 2011 at 1:22 AM, kunzmilan  wrote:

>
>
> On 22 kvě, 08:40, punnu  wrote:
> > Given 2 nos.  we need to divide them without performing divison.
> > Please give a better solution than subtracting the nos. again and
> > again.
> > Try to multiply the smaler number and by a suitable number, subtract the
> product, compare, and repeat adding zeroes, if necessary.
> kunzmilan
>
> --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: first fit bin packing

2011-05-22 Thread ankit sambyal
@chinna:   the question asks for first fit, not best fit



On Sun, May 22, 2011 at 1:03 AM, pacific :-)  wrote:

> @ankit: I didn't undertand ur explanation for why a sort wont work.
>
> 1. Sort the bins by the left over space.
> 2. For a new value to be inserted , do a binary search and locate the best
> fit.
> 3. For the bucket we are adding this new element , its left over space
> reduces ...so now do a binary search to find its new location and move it to
>  the new location.
>
> O(nlogn) {for initial sort} +  n * { logn (for search ) + logn (for moving
> the box to which we are adding ) }
> Total complexity = O(nlogn)
>
> Correct me if i'm wrong.
>
> On Tue, May 17, 2011 at 7:05 PM, ankit sambyal wrote:
>
>> @monsieur:  we can't solve the problem by the way u suggest because we
>> have to sort it by bin number but we have to find the first fit according to
>> the left over space in the bin. So, in the worst case it will take more than
>> O(n*log(n))time  If u need any clarifications feel free to comment
>>
>>
>> regards,
>> Ankit
>>
>>
>>
>>
>>
>>
>> On Tue, May 17, 2011 at 5:52 AM, MONSIEUR  wrote:
>>
>>> guys why cant we simply sort bins using merge sort or any comparison
>>> sort and then use binary search to find out the first available
>>> bin.t(n)=O(nlgn)+n*(lgn)=O(nlgn).
>>>
>>> --
>>> 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, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> regards,
> chinna.
>
>  --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Divide 2 nos. without DIVISON

2011-05-22 Thread kunzmilan


On 22 kvě, 08:40, punnu  wrote:
> Given 2 nos.  we need to divide them without performing divison.
> Please give a better solution than subtracting the nos. again and
> again.
> Try to multiply the smaler number and by a suitable number, subtract the 
> product, compare, and repeat adding zeroes, if necessary.
kunzmilan

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: first fit bin packing

2011-05-22 Thread pacific :-)
@ankit: I didn't undertand ur explanation for why a sort wont work.

1. Sort the bins by the left over space.
2. For a new value to be inserted , do a binary search and locate the best
fit.
3. For the bucket we are adding this new element , its left over space
reduces ...so now do a binary search to find its new location and move it to
 the new location.

O(nlogn) {for initial sort} +  n * { logn (for search ) + logn (for moving
the box to which we are adding ) }
Total complexity = O(nlogn)

Correct me if i'm wrong.

On Tue, May 17, 2011 at 7:05 PM, ankit sambyal wrote:

> @monsieur:  we can't solve the problem by the way u suggest because we have
> to sort it by bin number but we have to find the first fit according to the
> left over space in the bin. So, in the worst case it will take more than
> O(n*log(n))time  If u need any clarifications feel free to comment
>
>
> regards,
> Ankit
>
>
>
>
>
>
> On Tue, May 17, 2011 at 5:52 AM, MONSIEUR  wrote:
>
>> guys why cant we simply sort bins using merge sort or any comparison
>> sort and then use binary search to find out the first available
>> bin.t(n)=O(nlgn)+n*(lgn)=O(nlgn).
>>
>> --
>> 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, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> 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, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
regards,
chinna.

-- 
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, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Popular Puzzle of the week

2011-05-22 Thread Lavesh Rawat
*Hi,*
*
*
*Based on most comments, The popular puzzle of the last week is*

*
http://dailybrainteaser.blogspot.com/2011/05/like-dislike-mathamatical-quiz-17-may.html?lavesh=lavesh
*


*Please subscribe and follow this blog to show your liking to the blog.*



-- 

"Never explain yourself. Your friends don’t need it and
your enemies won’t believe 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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.