当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3971:Scales

题目描述
You are given scales for weighing loads. On the left side lies a single stone of known weight W<2N. You own a set of N different weights, weighing 1, 2, 4 ... 2(N-1) units of mass respectively. Determine how many possible ways there are of placing some weights on the sides of the scales; so as to balance them (put them in a state of equilibrium). Output this value modulo a small integer D.
输入解释
The input begins with an integer t, the number of test cases. Then t test cases follow. For each test case, the first line contains three integers: N L D, where N denotes the number of weights at your disposal, L is the length of the binary representation of number W, and D is the modulus (1<=L<=N<=1000000, 2<=D<=100). The second line contains the value of W, encoded in the binary system as a sequence of exactly L characters 0 or 1 without separating spaces.
输出解释
For each test case, output a single line containing one integer - the calculated number of possible weight placements, modulo D.
输入样例
2
6 4 6
1000
6 6 100
100110
输出样例
3
5

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3971

最后修改于 2020-10-29T07:17:02+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000 65536