/** * @file 2561.cpp * @brief yukicoder No.2561 みんな大好きmod 998 * @author Keitaro Naruse * @date 2023-12-02 * @copyright MIT License * @details https://yukicoder.me/problems/no/2561 * */ // # Solution #include #include template < class T > std::ostream& operator<<( std::ostream& os, const std::vector< T >& v ) { for( auto it = v.begin( ); it != v.end( ); it++ ) { os << *it << ( it == --v.end( ) ? "" : " " ); } return os; } int dfs( int k, int from, std::vector< int >& indicies, int N, int K, const std::vector< int >& A ) { if( k == K ) { // std::cerr << indicies << std::endl; long long sum = 0LL; for( int i = 0; i < K; i++ ) { sum += A.at( indicies.at( i ) ); } if( sum % 998244353LL <= sum % 988LL ) { return 1; } return 0; } int count = 0; for( int i = from; i < N; i++ ) { indicies.at( k ) = i; count += dfs( k + 1, i + 1, indicies, N, K, A ); } return count; } int main( ) { // Read N = [ 1, 28 ], K = min( 8, N ) int N, K; std::cin >> N >> K; // Read Ai = [ 0, 10^9 ] std::vector< int > A( N, 0 ); for( int i = 0; i < N; i++ ) { std::cin >> A.at( i ); } // Main::Preprocess // Main::Find a solution std::vector< int > indicies( K, 0 ); int answer = dfs( 0, 0, indicies, N, K, A ) % 998; // Main::Output a solution std::cout << answer << std::endl; // Finalize return 0; }