D. Hamming distance is used in the data transmission error control code inside, Hamming distance is a concept, it represents two (the same length) word corresponds to the number of different digits,
We use D (x, y) to denote the Hamming distance between two characters and X, Y. The number of two strings is different or operation, and the statistic result is 1, then this is the Hamming distance.
The minimum Hamming distance (the Hamming distance of some 2 strings is the smallest) is obtained by giving N strings.
S. Random number method ...
C. Can you live, look at the face ...
#include <iostream>#include<stdio.h>#include<string.h>#include<stdlib.h>#include<time.h>using namespacestd;intMain () {//cout<<rand_max<<endl;//32767 intT; intN; Charstr[100005][Ten]; intnum[100005]; inti; intJ; intmi; intfuck; intshit; inttmp; intsum; scanf ("%d",&T); while(t--) {scanf ("%d",&N); for(i=0; i<n;++i) {scanf ("%s", Str[i]); } memset (num,0,sizeof(num)); for(i=0; i<n;++i) { for(j=0;j<5;++j) { if('0'<=str[i][j]&&str[i][j]<='9') {Num[i]= (num[i]<<4) + (str[i][j]-'0'); } Else{Num[i]= (num[i]<<4)+(Ten+str[i][j]-'A'); }}} mi= +; Srand (Time (NULL)); for(i=0;i<400005;++i) {Fuck= (rand () *rand ())%N;//This is a look-face code ... Shit= (rand () *rand ())%N; if(fuck==shit) { Continue; } tmp=num[fuck]^Num[shit]; Sum=0; while(tmp>0) {sum=sum+ (tmp&1); TMP>>=1; } if(sum<mi) {mi=sum; }} printf ("%d\n", MI); } return 0;}
View Code
HDU 4712 Hamming Distance (random number method)