usaco-3.2-kimbits-pass

來源:互聯網
上載者:User

標籤:style   blog   color   io   os   ar   for   div   sp   

就這個比較清晰:

/*ID: qq104801LANG: 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 35int 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 TrainingGrader Results     4 users onlineCHN/2 USA/2USER: cn tom [qq104801]TASK: kimbitsLANG: C++Compiling...Compile: OKExecuting...   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 1234567890Keep up the good work!Thanks for your submission!

 

usaco-3.2-kimbits-pass

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.