diff --git a/TangDou/51NOD/1909.cpp b/TangDou/51NOD/1909.cpp index d385084..fb6a761 100644 --- a/TangDou/51NOD/1909.cpp +++ b/TangDou/51NOD/1909.cpp @@ -34,13 +34,14 @@ aaa 第i行,第j个 i从1开始,到n=4结束 j从1开始,到i结束 +找出递推关系式: x=n-i + (j-1)*2 y=(n-i)*sqrt(3) - */ bool check(Node a, Node b, Node c) { - // n - i + (j - 1) * 2, (n - i) * sqrt(3) + // x= n - i + (j - 1) * 2 + // y= (n - i) * sqrt(3) if (a.c != b.c || a.c != c.c || b.c != c.c) return false; double ax = (n - a.x + (a.y - 1) * 2); @@ -63,8 +64,8 @@ int main() { freopen("51nod_1909_2_in.txt", "r", stdin); #endif - cin >> n; - string s; + cin >> n; // 4 + string s; // abccddadca cin >> s; // 先把字符串存入char[][] int idx = 0; diff --git a/TangDou/51NOD/kapibala.cpp b/TangDou/51NOD/kapibala.cpp new file mode 100644 index 0000000..46a2025 --- /dev/null +++ b/TangDou/51NOD/kapibala.cpp @@ -0,0 +1,49 @@ +#include +using namespace std; +const int N = 110; +char a[N][N]; +const double eps = 1e-8; +int n; +struct Node { + int x, y; + char c; +}; +vector q; +bool check(Node a, Node b, Node c) { + if (a.c != b.c || a.c != c.c || b.c != c.c) return false; + double ax = (n - a.x + (a.y - 1) * 2); + double bx = (n - b.x + (b.y - 1) * 2); + double cx = (n - c.x + (c.y - 1) * 2); + double ay = (n - a.x) * sqrt(3); + double by = (n - b.x) * sqrt(3); + double cy = (n - c.x) * sqrt(3); + double c1 = (ax - bx) * (ax - bx) + (ay - by) * (ay - by); + double c2 = (ax - cx) * (ax - cx) + (ay - cy) * (ay - cy); + double c3 = (bx - cx) * (bx - cx) + (by - cy) * (by - cy); + if (abs(c1 - c2) < eps && abs(c1 - c3) < eps && abs(c2 - c3) < eps) return true; + return false; +} +int main() { + cin >> n; + string s; + cin >> s; + int idx = 0; + for (int i = 1; i <= n; i++) + for (int j = 1; j <= i; j++) + a[i][j] = s[idx++]; + for (int i = 1; i <= n; i++) + for (int j = 1; j <= i; j++) + q.push_back({i, j, a[i][j]}); + vector res; + for (int i = 0; i < q.size(); i++) + for (int j = i + 1; j < q.size(); j++) + for (int k = j + 1; k < q.size(); k++) + if (check(q[i], q[j], q[k])) res.push_back(q[i].c); + if (res.size() == 0) + cout << "No Solution" << endl; + else{ + sort(res.begin(), res.end()); + for (char x : res) cout << x; + } + return 0; +} \ No newline at end of file diff --git a/TangDou/51NOD/枚举每个金矿.ggb b/TangDou/51NOD/枚举每个金矿.ggb new file mode 100644 index 0000000..11d271d Binary files /dev/null and b/TangDou/51NOD/枚举每个金矿.ggb differ