usaco-3.2-kimbits-pass

就这个比较清晰:

/*
ID: qq104801
LANG: C++
TASK: kimbits
*/

#include <iostream>
#include <fstream>
#include <cstring>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

#define NMAX 35

int a[NMAX][NMAX];
int d[NMAX][NMAX];

void test()
{    
    freopen("kimbits.in","r",stdin);
    freopen("kimbits.out","w",stdout);
    int n,l;
    long long x;
    cin>>n>>l>>x;
    int i,j;
    for(i=0;i<=n;i++){
        a[i][0]=1;
        d[i][0]=1;
    }
    for(i=0;i<=l;i++)
        d[0][i]=1;    
        
    for(i=1;i<=n;i++)
    {
        d[i][0]=1;
        for(j=1;j<=l;j++)
        {
            a[i][j]=a[i-1][j]+a[i-1][j-1];
            d[i][j]=a[i][j]+d[i][j-1];
        }
    }
    j=l;
    int leave=x-1;
    for(i=n-1;i>=0;i--)
    {
        if(leave>=d[i][j])
        {
            leave-=d[i][j];
            j--;
            cout<<1;
        }
        else
            cout<<0;
    }
    cout<<endl;
}

int main () 
{        
    test();        
    return 0;
}

test data:

USACO Training
Grader Results     
4 users online
CHN/2 USA/2

USER: cn tom [qq104801]
TASK: kimbits
LANG: C++

Compiling...
Compile: OK

Executing...
   Test 1: TEST OK [0.005 secs, 3380 KB]
   Test 2: TEST OK [0.003 secs, 3380 KB]
   Test 3: TEST OK [0.003 secs, 3380 KB]
   Test 4: TEST OK [0.003 secs, 3380 KB]
   Test 5: TEST OK [0.005 secs, 3380 KB]
   Test 6: TEST OK [0.005 secs, 3380 KB]
   Test 7: TEST OK [0.005 secs, 3380 KB]
   Test 8: TEST OK [0.005 secs, 3380 KB]
   Test 9: TEST OK [0.005 secs, 3380 KB]
   Test 10: TEST OK [0.005 secs, 3380 KB]
   Test 11: TEST OK [0.008 secs, 3380 KB]
   Test 12: TEST OK [0.005 secs, 3380 KB]
   Test 13: TEST OK [0.005 secs, 3380 KB]

All tests OK.

Your program ('kimbits') produced all correct answers! This is your submission #6 for this problem. Congratulations!

Here are the test data inputs:

------- test 1 ----
4 2 1
------- test 2 ----
1 1 2
------- test 3 ----
8 4 30
------- test 4 ----
10 2 56
------- test 5 ----
7 7 64
------- test 6 ----
18 3 300
------- test 7 ----
21 10 1048576
------- test 8 ----
24 20 12936478
------- test 9 ----
31 24 10000000
------- test 10 ----
31 31 2147483648
------- test 11 ----
31 26 12345678
------- test 12 ----
31 26 123456789
------- test 13 ----
31 26 1234567890

Keep up the good work!
Thanks for your submission!

 

posted on 2014-09-11 17:43  深蓝无忌  阅读(145)  评论(0编辑  收藏  举报

导航