A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move vertically or horizontally from its current position and two rooks attack each other if one is on the path of the other. In the following fig…
Clarke and problem 问题描述 克拉克是一名人格分裂患者.某一天,克拉克分裂成了一个学生,在做题. 突然一道难题难到了克拉克,这道题是这样的: 给你nn个数,要求选一些数(可以不选),把它们加起来,使得和恰好是pp的倍数(00也是pp的倍数),求方案数. 对于nn很小的时候,克拉克是能轻易找到的.然而对于nn很大的时候,克拉克没有办法了,所以来求助于你. 输入描述 第一行一个整数T(1 \le T \le 10)T(1≤T≤10),表示数据的组数. 每组数据第一行是两个正整数n,…
Problem Description In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence <A, B, D> is a subsequence of <A,…