|
|
вернуться в форумis java's BigDecimal acceptable? I solve reccurence, then pow to n(which takes log n to quickpow), but it's also TL. How can i improve this not writing my own long arithmetic? Re: is java's BigDecimal acceptable? It can be solved only with 2 divisions in BigDecimal, but answer length is about 32000 so [maybe] toString gives TLE on conversion binary data to decimal representation. If somebody knows, how to solve this problem - please tell me Re: is java's BigDecimal acceptable? Послано bve 29 окт 2008 00:05 2^n = 10^(n*lg(2)) My AC solution: int n0 = (int) (Math.log10(2f) * (n - 1)); int n1 = (int) (Math.log10(2f) * n); int n2 = (int) (Math.log10(2f) * (n + 1)); int len = n1; if (n1 == n2 && n1 == n0 + 1 && n % 2 != 0) { len = n0; } Answer is len. Re: is java's BigDecimal acceptable? I thought that this problem's solution is : t= (n-(n%10)) /4 +1 if(n>=30) { t=t+1; x=n-n%10; if(n>39&&((x/10)%2)) t=t+(x-30)/20; if(n>49&&((n-n%10)%4==0)) t=t+(x-40)/20; } t= t+ (n%10)/4; cout<<t; but it got WA#8. And i don't understand "if(n==1 && n1==n0+1 && n%2!=0)" statement are for what tests? Would you mind explaining for me! Thanks! Re: is java's BigDecimal acceptable? bve, your way is brilliant. Thank you! Re: is java's BigDecimal acceptable? bve, any links to why it works? Re: is java's BigDecimal acceptable? Thanks you! |
|
|