首页 > 代码库 > usaco-3.2-kimbits-pass
usaco-3.2-kimbits-pass
就这个比较清晰:
/*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个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。