@avi dullu: explanation of your code plz.. On Jul 3, 3:57 am, Avi Dullu <avi.du...@gmail.com> wrote: > Another alternative soln. > > int rec_cut(int l, int k) { > if (l == k) return 0; > int tmp = k - (l>>1); > return 1 + rec_cut(l>>1, tmp <= 0 ? k : tmp); > > } > > int main() { > int l, k; > scanf("%d%d", &l, &k); > printf("%d\n", rec_cut(l, k)); > return 0; > > } > > Veni Vedi Slumber ! > > On Sat, Jul 2, 2011 at 9:47 PM, varun pahwa <varunpahwa2...@gmail.com>wrote: > > > > > > > @sunny thnx for the correction. > > > On Sat, Jul 2, 2011 at 9:16 AM, varun pahwa <varunpahwa2...@gmail.com>wrote: > > >> @sunny ya i wanted to write the while(k % m == 0) > > >> On Sat, Jul 2, 2011 at 3:47 AM, sameer.mut...@gmail.com < > >> sameer.mut...@gmail.com> wrote: > > >>> n&n-1 is the expression to find out if n is a power of 2...If n&n-1 > >>> returns 0 its a power of 2 else its not. > >>> And what sunny said is also ryt.... > > >>> On Sat, Jul 2, 2011 at 3:47 PM, sunny agrawal > >>> <sunny816.i...@gmail.com>wrote: > > >>>> @cegprakash > >>>> Expression resets the least significant set bit > > >>>> On Sat, Jul 2, 2011 at 3:20 PM, mohit goel > >>>> <mohitgoel291...@gmail.com>wrote: > > >>>>> May be this can work.....give any counter example... > >>>>> int count; > >>>>> main() > >>>>> { > >>>>> int l,rope,cuts; > >>>>> scanf("%d%d",&l,&rope); > >>>>> count =0; > > >>>>> find_cuts(l,rope); > >>>>> printf("cuts needed is %d",count); > >>>>> getch(); > >>>>> return 0; > >>>>> } > > >>>>> int find_cuts(int l,int rope) > > >>>>> { > > >>>>> if(l==rope) > >>>>> return count; > >>>>> count++; > >>>>> printf("%d",count); > >>>>> l=l/2; > >>>>> if(l==rope) > >>>>> return count; > >>>>> if(rope>l) > >>>>> rope =rope-l; > > >>>>> find_cuts(l,rope); > > >>>>> } > > >>>>> -- > >>>>> 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. > > >>>> -- > >>>> Sunny Aggrawal > >>>> B-Tech IV year,CSI > >>>> Indian Institute Of Technology,Roorkee > > >>>> -- > >>>> 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. > > >> -- > >> Varun Pahwa > >> B.Tech (IT) > >> 7th Sem. > >> Indian Institute of Information Technology Allahabad. > >> Ph : 09793899112 ,08011820777 > >> Official Email :: rit2008...@iiita.ac.in > >> Another Email :: varunpahwa.ii...@gmail.com > > >> People who fail to plan are those who plan to fail. > > > -- > > Varun Pahwa > > B.Tech (IT) > > 7th Sem. > > Indian Institute of Information Technology Allahabad. > > Ph : 09793899112 ,08011820777 > > Official Email :: rit2008...@iiita.ac.in > > Another Email :: varunpahwa.ii...@gmail.com > > > People who fail to plan are those who plan to fail. > > > -- > > 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.