|
|
вернуться в форум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); } } I got WA6 too...can you please tell me the case? 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. Could you explain, why it is better ? |
|
|