|
|
back to boardWA6 Posted by hatred 13 Aug 2011 01:33 where is my mistake? #include <cstdio> #include <cmath> inline int lb(int n) { return ceil(log(double(n))/log(2.0)); } int main() { int n,k; scanf("%d%d",&n,&k); if (n<=k) printf("%d",lb(n)); else { int ans=lb(k); n-=1l << ans; ans+=n/k; if (n%k) ++ans; printf("%d",ans); } } Re: WA6 Posted by Jobed 17 Apr 2014 13:05 I got WA6 too...can you please tell me the case? Re: WA6 Posted by BillSu 26 Apr 2014 12:17 Your formula is wrong. Re: WA6 Whoever gets Wrong Answer at 6th test, try to change your way of finding the power of two. My solution got WA#6 when I calculated power of two this way: power = ceil(log(x)/log(2)); Better calculate it by multiplying it. Re: WA6 Could you explain, why it is better ? |
|
|