Merge branch 'main' of http://10.10.14.176:3000/huanghai/python
commit
ebe26b08c7
@ -1 +1 @@
|
||||
https://zhuanlan.zhihu.com/p/259191634
|
||||
https://gitee.com/devcpp/devcpp
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,10 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long LL;
|
||||
int main() {
|
||||
int a, b, c;
|
||||
int x;
|
||||
cin >> a >> b >> c;
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
bool issimilar(string a, string b) {
|
||||
if (abs((int)a.size() - (int)b.size()) > 1)
|
||||
return false;
|
||||
if (a.size() == b.size()) {
|
||||
int cnt = 0;
|
||||
for (int i = 0; i < a.size(); i++) {
|
||||
if (a[i] != b[i])
|
||||
if (cnt++ > 1)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
int cnt = 0;
|
||||
if (a.size() > b.size())
|
||||
swap(a, b);
|
||||
int j = 0;
|
||||
for (int i = 0; i < a.size();) {
|
||||
if (a[i] != b[j]) {
|
||||
cnt++;
|
||||
j++;
|
||||
} else {
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
if (cnt > 1)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int T;
|
||||
cin >> T;
|
||||
while (T--) {
|
||||
string a, b;
|
||||
cin >> a >> b;
|
||||
if (issimilar(a, b)) {
|
||||
cout << "similar" << endl;
|
||||
} else
|
||||
cout << "not similar" << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
AAAA6AAAA6
|
@ -0,0 +1,87 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 256;
|
||||
int b[N];
|
||||
|
||||
int toDec(char a, char b) {
|
||||
int res = 0;
|
||||
if (a >= 'A' && a <= 'F')
|
||||
res += (a - 'A' + 10) * 16;
|
||||
else
|
||||
res += (a - '0') * 16;
|
||||
if (b >= 'A' && b <= 'F')
|
||||
res += b - 'A' + 10;
|
||||
else
|
||||
res += b - '0' ;
|
||||
return res;
|
||||
}
|
||||
|
||||
string toHex(int x) {
|
||||
int a = x % 16;
|
||||
int b = x / 16;
|
||||
char c1, c2;
|
||||
if (a >= 10)
|
||||
c1 = 'A' + a - 10;
|
||||
else
|
||||
c1 = a + '0';
|
||||
if (b >= 10)
|
||||
c2 = 'A' + b - 10;
|
||||
else
|
||||
c2 = b + '0';
|
||||
string res;
|
||||
res.push_back(c2);
|
||||
res.push_back(c1);
|
||||
return res;
|
||||
}
|
||||
vector<string>q;
|
||||
|
||||
vector<int>vec;
|
||||
|
||||
int main() {
|
||||
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
string s;
|
||||
cin >> s;
|
||||
q.push_back(s);
|
||||
for (int j = 0; j < s.size(); j += 2) {
|
||||
char c1 = s[j], c2 = s[j + 1];
|
||||
int k = toDec(c1, c2);
|
||||
b[k]++;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int mx = 0, mx_id = -1;
|
||||
for (int j = 0; j < 256; j++)
|
||||
if (b[j] > mx) {
|
||||
mx = b[j];
|
||||
mx_id = j;
|
||||
}
|
||||
vec.push_back(mx_id);
|
||||
|
||||
b[mx_id] = -1;
|
||||
}
|
||||
for (int i = 0; i < min(16, (int)vec.size()); i++)
|
||||
cout << toHex(vec[i]) ;
|
||||
cout << endl;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < q[0].size(); j += 2) {
|
||||
int c1 = q[i][j], c2 = q[i][j + 1];
|
||||
int x = toDec(c1, c2);
|
||||
int mi = INT_MAX;
|
||||
int mi_p = 0;
|
||||
for (int k = 0; k < min(16, (int)vec.size()); k++) {
|
||||
if (mi > abs(vec[k] - x)) {
|
||||
mi = abs(vec[k] - x);
|
||||
mi_p = k;
|
||||
}
|
||||
}
|
||||
cout << toHex(mi_p)[1];
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
ofstream fout;
|
||||
fout.open("1.txt");
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
if (i % 5 == 0) {
|
||||
int x = 6;
|
||||
fout << x;
|
||||
} else {
|
||||
char ch = 'A';
|
||||
fout << ch;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Binary file not shown.
Loading…
Reference in new issue