Topic Portal
1 /*2 Test Instructions: (a0*x^ (2^0) +1) * (A1 * x^ (2^1) +1) *.......* (an-1 * x^ (2^ (n-1)) +1) in the equation, the P-sub-square coefficient of x3 The bits operation:p=2^i+2^j+2^k+..., in binary notation is the appearance of 1.4 For example: 10 of the binary is 1010, 10 = 2^3 + 2^1 = 8 + 2, and each binary number has a related a[i], p shift operation, the cumulative modulo on the line5 */6#include <cstdio>7#include <cmath>8#include <algorithm>9#include <iostream>Ten#include <cstring> One using namespacestd; A - Const intMAXN = 1e6 +Ten; - Const intINF =0x3f3f3f3f; the - intMainvoid)//F Alice and Bob - { - //freopen ("F.txt", "R", stdin); + - intT; + while(SCANF ("%d", &t) = =1) A { at while(t--) - { - intN, a[ -], q; - Long Longp; -scanf ("%d", &n); - for(intI=0; i<n; ++i) in { -scanf ("%d", &a[i]); to } +scanf ("%d", &q); - the while(q--) * { $scanf ("%lld", &p);Panax Notoginseng intTMP =1;inti =0; - while(P) the { + if(I >=N) A { theTMP =0; Break; + } - if(P &1) TMP *=A[i]; $++i; $P >>=1; -TMP%= -; - } theprintf ("%d\n", TMP); - } Wuyi } the } - Wu return 0; -}
Bit operation F Alice and Bob