ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1131. Copying

WA6
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
Posted by Siroj Matchanov [TUIT] 9 Feb 2018 04:11
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
Posted by Sergey Nikolaev 5 Apr 2018 20:27
Could you explain, why it is better ?