标签:
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1806 Accepted Submission(s): 714
#pragma comprint(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<string> #include<iostream> #include<cstring> #include<cmath> #include<stack> #include<queue> #include<vector> #include<map> #include<stdlib.h> #include<time.h> #include<algorithm> #define LL __int64 #define FIN freopen("in.txt","r",stdin) using namespace std; const int MAXN=100000+5; const int MAX=1<<21; const int INF=0x3f3f3f3f; int a[MAX+5],num[MAXN]; int kase,n; void init() { for(int i=0;i<=MAX;i++) { int cnt=0; for(int j=0;j<21;j++) if(i & (1<<j)) cnt++; a[i]=cnt; } } int main() { init(); scanf("%d",&kase); while(kase--) { scanf("%d",&n); for(int i=0;i<n;i++) scanf("%x",&num[i]); int ans=INF; srand( (unsigned)time( NULL ) ); for(int i=0;i<900000;i++) { int x=rand()%n; int y=rand()%n; if(x==y) continue; ans=min(ans,a[num[x]^num[y]]); } printf("%d\n",ans); } return 0; }
HDU 4712 Hamming Distance (随机函数)
标签:
原文地址:http://www.cnblogs.com/clliff/p/4743521.html