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!

 

转载于:https://www.cnblogs.com/dpblue/p/3966983.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值