#include #include #include using ull = unsigned long long; #define NV(v)#v<<" : "<<(v) static ull t, k, n, m, ans; static std::map fact_map; static std::map,ull> C_map; static ull fact(const ull n)noexcept{ if(n==0)return 1; const auto it = fact_map.find(n); if(it != fact_map.end())return (*it).second; ull ret {1}; for(ull i{2};i<=n;i++){ ret*=i; } fact_map.insert({n,ret}); return ret; } static ull C(const ull n, const ull m)noexcept{ const auto it = C_map.find({n,m}); if(it!=C_map.end())return (*it).second; const ull ret = (fact(n))/(fact(m)*fact(n-m)); C_map.insert({{n,m},ret}); return ret; } int main(){ // std::cout<>t>>k; for(ull i {0};i>n>>m; ans = 0; for(ull i {0};i<=n;i++){ for(ull j{0};j<=std::min(i,m);j++){ if(C(i,j)%k==0)ans++; } } std::cout<