标签:style blog color os io ar for div sp
呵呵,搞了半天,也没有搞明白,网上参考了一下成功者,下来再仔细研究下。
/* ID: qq104801 LANG: C++ TASK: nocows */ #include <iostream> #include <fstream> #include <string> #include <vector> #include <cstdio> #include <algorithm> using namespace std; int n,k; int d[201][101]; void test() { freopen("nocows.in","r",stdin); freopen("nocows.out","w",stdout); cin>>n>>k; d[1][0]=1;d[1][1]=1; int i,j,p,q,res=0; for(i=3;i<=n;i+=2) { int upper=i>>1; for(j=1;j<=upper;j+=2) for(p=1;p<=d[j][0];++p) for(q=1;q<=d[i-1-j][0];++q) { if(d[j][p] && d[i-1-j][q]) { int height=(p>q?p:q)+1; if(height>d[i][0]) d[i][0]=height; res=(d[j][p]*d[i-1-j][q])<<1; if(i-1-j==j) res>>=1; d[i][height]=(d[i][height]+res)%9901; } } } cout<<d[n][k]%9901<<endl; } int main () { test(); return 0; }
test data:
USER: cn tom [qq104801] TASK: nocows LANG: C++ Compiling... Compile: OK Executing... Test 1: TEST OK [0.003 secs, 3448 KB] Test 2: TEST OK [0.003 secs, 3448 KB] Test 3: TEST OK [0.003 secs, 3448 KB] Test 4: TEST OK [0.008 secs, 3448 KB] Test 5: TEST OK [0.005 secs, 3448 KB] Test 6: TEST OK [0.011 secs, 3448 KB] Test 7: TEST OK [0.027 secs, 3448 KB] Test 8: TEST OK [0.022 secs, 3448 KB] Test 9: TEST OK [0.024 secs, 3448 KB] Test 10: TEST OK [0.022 secs, 3448 KB] Test 11: TEST OK [0.038 secs, 3448 KB] Test 12: TEST OK [0.043 secs, 3448 KB] All tests OK. YOUR PROGRAM (‘nocows‘) WORKED FIRST TIME! That‘s fantastic -- and a rare thing. Please accept these special automated congratulations. Here are the test data inputs: ------- test 1 ---- 5 3 ------- test 2 ---- 9 4 ------- test 3 ---- 35 7 ------- test 4 ---- 15 4 ------- test 5 ---- 75 47 ------- test 6 ---- 99 15 ------- test 7 ---- 172 44 ------- test 8 ---- 165 65 ------- test 9 ---- 177 57 ------- test 10 ---- 198 56 ------- test 11 ---- 199 99 ------- test 12 ---- 199 77 Keep up the good work! Thanks for your submission!
标签:style blog color os io ar for div sp
原文地址:http://www.cnblogs.com/dpblue/p/3957839.html