I think its problem of overflow? the input data is 10^18.Otherwise the problem is trivial....
On Sun, Jul 3, 2011 at 7:02 PM, cegprakash <cegprak...@gmail.com> wrote: > i was actually trying this problem.. > > www.spoj.pl/problems/LQDCANDY > > I'm getting WA still.. > > > #include<math.h> > #include<stdio.h> > int cnt; > inline int find_cuts(int l,int rope) > { > if(l==rope) > return cnt; > cnt++; > l=l/2; > if(l==rope) > return cnt; > if(rope>l) > rope-=l; > > return find_cuts(l,rope); > } > > int main(){ > int t; > scanf("%d",&t); > while(t--){ > int n,needed; > scanf("%d",&n); > int x=log2(n); > int p=(int)pow(2,x); > if(n!=p) > needed=(int)pow(2,x+1); > else{ > printf("%d 0\n",n); > continue; > } > if(n%2==1) > printf("%d %d\n",needed,(int)log2(needed)); > else{ > cnt=0; > printf("%d %d\n",needed,find_cuts(needed,n)); > > } > } > } > > -- > 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. > > -- 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 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.