标签:
2 2 12345 54321 4 12345 6789A BCDEF 0137F
6 7我想对出题的人说一句话,坑爹的题目,坑爹随机算法其中可能提交会出现错误,但是多提交几次就对了(建议大家该为1e6就可以了)#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <cmath> #include <cstdio> #include <string> #include <ctime> using namespace std; typedef long long LL; const int MAXN = 1e5 + 5; const int INF = 0x3f3f3f3f; int T, n; int A[MAXN]; int Get_Num(int m) { int ret = 0; while(m) { ret += (m & 1); m >>= 1; } return ret; } int main() { scanf("%d", &T); while(T --) { scanf("%d", &n); for(int i = 0; i < n; i ++) { scanf("%X", &A[i]); } srand(time(NULL)); int Min = INF; for(int i = 0; i < 1e5; i ++) { int a = rand() % n; int b = rand() % n; if(a == b) continue; Min = min(Min, Get_Num(A[a] ^ A[b])); } printf("%d\n",Min); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
HDU - 4712 Hamming Distance(坑爹的随机数算法 + 暴力求解)
标签:
原文地址:http://blog.csdn.net/qq_18661257/article/details/47783325