I/P 30 105 1055 0 O/P 0 1 1
your code gives 1 1 1 (Copied from comments below the statement on Spoj ) -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad <http://gplus.to/amolsharma99> <http://twitter.com/amolsharma99><http://in.linkedin.com/pub/amol-sharma/21/79b/507><http://youtube.com/amolsharma99> On Sat, Aug 27, 2011 at 11:13 PM, Piyush Kapoor <pkjee2...@gmail.com> wrote: > There is nothing much particular to java,, > Here is the code(simply copy pasted from the above one) in C:: > int main(){ > char ar[1000000]; > int dp[10000000]; > scanf("%s",ar); > if(ar[l-1]!='0') > dp[l-1]=1; > for(int j=l-2;j>=0;j--) > { > int a=ar[j]-'0',b=ar[j+1]-'0'; > if(j==(l-2) && (10*a+b)<=26) > { > if(a!=0) > dp[j]=1+dp[j+1]; > } > else if(j==(l-2) && (10*a+b)>26) > dp[j]=dp[j+1]; > else if(j!=(l-2) && (10*a+b)<=26) > { > if(a!=0) > dp[j]=dp[j+1]+dp[j+2]; > } > else > { > dp[j]=dp[j+1]; > } > } > printf("%d\n",dp[0]); > return 0; > } > > -- > *Regards,* > *Piyush Kapoor,* > *2nd year,CSE > IT-BHU* > > -- > 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.