Bit operation F Alice and Bob

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.