/* vim: set ts=2 sts=2 sw=2 si foldmethod=marker: */ // {{{ includes // IO #include #include #include #include #include #include // Utility #include #include #include #include #include #include #include #include // Data structures #include #include #include #include #include #include #include #include // I want easy access to STL and things like hash_map using namespace std; using namespace std::tr1; // Needed for hash_map /* namespace __gnu_cxx { template<> struct hash { int operator()(const std::string& x) const { return hash()(x.c_str()); } }; } */ // }}} // {{{ utility routines and such // stolen from http://www.ddj.com/cpp/184403801 template class StringTok { public: StringTok(const T& seq, typename T::intype pos = 0) : seq_(seq) , pos_(pos) { } T operator()(const T& delim); private: const T& seq_; typename T::intype pos_; }; template T StringTok::operator()(const T& delim) { T token; if(pos_ != T::npos) { // start of found token typename T::intype first(seq_.find_first_not_of(delim.c_str(), pos_)); if (first != T::npos) { // length of found token typename T::intype num(seq_.find_first_of(delim.c_str(), first) - first); // do all the work off to the side token = seq_.substr(first, num); // done; now commit using // nonthrowing operations only pos_ = first + num; if (pos_ != T::npos) ++pos_; if (pos_ >= seq_.size()) pos_ = T::npos; } } return token; } // stolen from http://www.gotw.ca/gotw/029.htm for case-insensitive lexicographic compares struct ci_char_traits : public std::char_traits { static bool eq(char c1, char c2) { return toupper(c1) == toupper(c2); } static bool ne(char c1, char c2) { return toupper(c1) != toupper(c2); } static bool lt(char c1, char c2) { return toupper(c1) < toupper(c2); } static int compare(const char* s1, const char* s2, int n) { return strncasecmp(s1, s2, n); } static const char* find(const char* s, int n, char a) { while(n-- > 0 && toupper(*s) != toupper(a)) { ++s; } return s; } }; // no boost makes c++ angry; lexical cast comes in handy for string <=> int conversion without expliucitly writing out the streams all the time. template T lexical_cast(const S& arg) { stringstream interpreter; T result; if (!(interpreter << arg) || !(interpreter >> result) || !(interpreter >> std::ws).eof()) throw logic_error("bad lexical_cast"); return result; } // }}} // {{{ utility typedefs typedef vector vs; typedef vector vi; typedef std::basic_string ci_string; // }}} // {{{ problem-specific typedefs // }}} int main() { int cache[9][65]; cache[1][0] = 1; cache[1][1] = 1; cache[2][0] = 1; cache[2][1] = 4; cache[2][2] = 4; cache[2][3] = 0; cache[2][4] = 0; cache[3][0] = 1; cache[3][1] = 9; cache[3][2] = 26; cache[3][3] = 26; cache[3][4] = 8; cache[3][5] = 0; cache[3][6] = 0; cache[3][7] = 0; cache[3][8] = 0; cache[3][9] = 0; cache[4][0] = 1; cache[4][1] = 16; cache[4][2] = 92; cache[4][3] = 232; cache[4][4] = 260; cache[4][5] = 112; cache[4][6] = 16; cache[4][7] = 0; cache[4][8] = 0; cache[4][9] = 0; cache[4][10] = 0; cache[4][11] = 0; cache[4][12] = 0; cache[4][13] = 0; cache[4][14] = 0; cache[4][15] = 0; cache[4][16] = 0; cache[5][0] = 1; cache[5][1] = 25; cache[5][2] = 240; cache[5][3] = 1124; cache[5][4] = 2728; cache[5][5] = 3368; cache[5][6] = 1960; cache[5][7] = 440; cache[5][8] = 32; cache[5][9] = 0; cache[5][10] = 0; cache[5][11] = 0; cache[5][12] = 0; cache[5][13] = 0; cache[5][14] = 0; cache[5][15] = 0; cache[5][16] = 0; cache[5][17] = 0; cache[5][18] = 0; cache[5][19] = 0; cache[5][20] = 0; cache[5][21] = 0; cache[5][22] = 0; cache[5][23] = 0; cache[5][24] = 0; cache[5][25] = 0; cache[6][0] = 1; cache[6][1] = 36; cache[6][2] = 520; cache[6][3] = 3896; cache[6][4] = 16428; cache[6][5] = 39680; cache[6][6] = 53744; cache[6][7] = 38368; cache[6][8] = 12944; cache[6][9] = 1600; cache[6][10] = 64; cache[6][11] = 0; cache[6][12] = 0; cache[6][13] = 0; cache[6][14] = 0; cache[6][15] = 0; cache[6][16] = 0; cache[6][17] = 0; cache[6][18] = 0; cache[6][19] = 0; cache[6][20] = 0; cache[6][21] = 0; cache[6][22] = 0; cache[6][23] = 0; cache[6][24] = 0; cache[6][25] = 0; cache[6][26] = 0; cache[6][27] = 0; cache[6][28] = 0; cache[6][29] = 0; cache[6][30] = 0; cache[6][31] = 0; cache[6][32] = 0; cache[6][33] = 0; cache[6][34] = 0; cache[6][35] = 0; cache[6][36] = 0; cache[7][0] = 1; cache[7][1] = 49; cache[7][2] = 994; cache[7][3] = 10894; cache[7][4] = 70792; cache[7][5] = 282248; cache[7][6] = 692320; cache[7][7] = 1022320; cache[7][8] = 867328; cache[7][9] = 389312; cache[7][10] = 81184; cache[7][11] = 5792; cache[7][12] = 128; cache[7][13] = 0; cache[7][14] = 0; cache[7][15] = 0; cache[7][16] = 0; cache[7][17] = 0; cache[7][18] = 0; cache[7][19] = 0; cache[7][20] = 0; cache[7][21] = 0; cache[7][22] = 0; cache[7][23] = 0; cache[7][24] = 0; cache[7][25] = 0; cache[7][26] = 0; cache[7][27] = 0; cache[7][28] = 0; cache[7][29] = 0; cache[7][30] = 0; cache[7][31] = 0; cache[7][32] = 0; cache[7][33] = 0; cache[7][34] = 0; cache[7][35] = 0; cache[7][36] = 0; cache[7][37] = 0; cache[7][38] = 0; cache[7][39] = 0; cache[7][40] = 0; cache[7][41] = 0; cache[7][42] = 0; cache[7][43] = 0; cache[7][44] = 0; cache[7][45] = 0; cache[7][46] = 0; cache[7][47] = 0; cache[7][48] = 0; cache[7][49] = 0; cache[8][0] = 1; cache[8][1] = 64; cache[8][2] = 1736; cache[8][3] = 26192; cache[8][4] = 242856; cache[8][5] = 1444928; cache[8][6] = 5599888; cache[8][7] = 14082528; cache[8][8] = 22522960; cache[8][9] = 22057472; cache[8][10] = 12448832; cache[8][11] = 3672448; cache[8][12] = 489536; cache[8][13] = 20224; cache[8][14] = 256; cache[8][15] = 0; cache[8][16] = 0; cache[8][17] = 0; cache[8][18] = 0; cache[8][19] = 0; cache[8][20] = 0; cache[8][21] = 0; cache[8][22] = 0; cache[8][23] = 0; cache[8][24] = 0; cache[8][25] = 0; cache[8][26] = 0; cache[8][27] = 0; cache[8][28] = 0; cache[8][29] = 0; cache[8][30] = 0; cache[8][31] = 0; cache[8][32] = 0; cache[8][33] = 0; cache[8][34] = 0; cache[8][35] = 0; cache[8][36] = 0; cache[8][37] = 0; cache[8][38] = 0; cache[8][39] = 0; cache[8][40] = 0; cache[8][41] = 0; cache[8][42] = 0; cache[8][43] = 0; cache[8][44] = 0; cache[8][45] = 0; cache[8][46] = 0; cache[8][47] = 0; cache[8][48] = 0; cache[8][49] = 0; cache[8][50] = 0; cache[8][51] = 0; cache[8][52] = 0; cache[8][53] = 0; cache[8][54] = 0; cache[8][55] = 0; cache[8][56] = 0; cache[8][57] = 0; cache[8][58] = 0; cache[8][59] = 0; cache[8][60] = 0; cache[8][61] = 0; cache[8][62] = 0; cache[8][63] = 0; cache[8][64] = 0; int n, k; while (cin >> n >> k, n != 0) cout << cache[n][k] << endl; return 0; }