codeforces Gym 101063 C
Posted 灬从此以后灬
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces Gym 101063 C相关的知识,希望对你有一定的参考价值。
二进制转十进制 然后按位比较
传送门 http://codeforces.com/gym/101063
#include <cstdio> #include <cmath> #include <cstring> #include <cstdlib> #include <iostream> #include <sstream> #include <algorithm> #include <string> #include <queue> #include <vector> using namespace std; const int maxn= 100005; const double eps= 1e-6; const int inf = 0x3f3f3f3f; const int mod =3; typedef long long ll; typedef long double ld; int n,m; int a[maxn][15]; int b[maxn]; ll c[maxn]; ll d[maxn]; int main() { while(scanf("%d %d",&n,&m)!=EOF) { memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); for(int i=1;i<=n;i++) { int t; scanf("%d",&t); for(int j=1;j<=t;j++) { scanf("%d",&a[i][j]); b[i]+=(1<<(a[i][j]-1)); } c[b[i]]++; } for(int i=1;i<=1023;i++) { int k=i; d[i]=0; while(k>0) { if(k%2) d[i]++; //i转换成二进制有多少个1 k/=2; } //printf("%d %d\n",i,d[i]); } ll ans=0; ld r; cin>>r; for(int i=1;i<=1023;i++) { for(int j=i;j<=1023;j++) { int q=i&j,p=i|j; ld k=(ld)d[q]/(ld)d[p]; if(k>=r) { if(i!=j) ans+=c[i]*c[j]; else ans+=c[i]*(c[i]-1)/2; } } } printf("%I64d\n",ans); } }
以上是关于codeforces Gym 101063 C的主要内容,如果未能解决你的问题,请参考以下文章
C - Sleep Buddies Gym - 101063C 状压
Codeforces Gym 101142C:CodeCoder vs TopForces(搜索)
Codeforces Gym100971 C.Triangles-组三角形 (IX Samara Regional Intercollegiate Programming Contest Russia