ZOJ 3870 Team Formation

Source: Internet
Author: User

Topic Links:

http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3870

Exercises

If X XOR Y>max (× X/y), then there will be a difference in the highest bit of x and Y (binary representation), and for the highest bit position of the highest bit of the number, the highest bit size should be 0 in the same position.

Code:
1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 6typedefLong LongLL;7 Const intMAXN = 1e5 +Ten;8 9 intN;Ten  One intARR[MAXN]; A //Cnt[i] Indicates how many of the highest-level I - intcnt[ +]; -  the voidinit () { -memset (CNT,0,sizeof(CNT)); - } -  + intMain () { -     intTC; +scanf"%d", &TC); A      while(tc--) { at init (); -scanf"%d", &n); -          for(inti =0; i<n; i++) { -scanf"%d", &arr[i]); -              for(intj = -; J >=0; j--) { -                 if((1<< j) &Arr[i]) { incnt[j]++; Break; -                 } to             } +         } -LL ans =0; the          for(inti =0; i<n; i++) { *             intJ; $              for(j = -; J >=0; j--) {Panax Notoginseng                 if((1<< j) &Arr[i]) { -                      Break; the                 } +             } A              for(J-=1; J >=0; j--) { the                 if(((1<< j) &arr[i]) = =0) { +Ans + =Cnt[j]; -                 } $             } $         } -printf"%lld\n", ans); -     } the     return 0; -}

ZOJ 3870 Team Formation

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.