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 1081. Binary Lexicographic Sequence

what's wrong?
Posted by Alias (Alexander Prudaev) 15 Mar 2007 18:34
WA#9 But, Why? It' is right program!

    int p = n;
    for (int i = 0; i < n; i++)
    {
        if (f[p]>=k)    s[i] = '0';
        else
        {
            s[i] = '1';
            k -= f[p];
        }
        p--;
    }
    s[n] = 0;
    printf("%s\n",s);

f[1] = 1,
 f[2] = 2,
 f[i] = f[i-1]+f[i-2];

Edited by author 15.03.2007 18:38
Re: what's wrong?
Posted by Yashar Abbasov 17 Jan 2008 09:59
you forgot about -1. When k is bigger than all possible sequences then the answer is -1