From ea9b23f700bd27ecdffc836e0d07d52df2968ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Sat, 20 Jan 2024 12:14:30 +0800 Subject: [PATCH] 'commit' --- TangDou/LuoGuBook/{TestC.cpp => JinKuang.cpp} | 0 TangDou/LuoGuBook/TestBC.cpp | 18 ----- TangDou/LuoGuBook/ZhiMuSanJiaoXing.cpp | 75 +++++++++++++++++++ TangDou/LuoGuBook/ZhiMuSanJiaoXing.in | 2 + 4 files changed, 77 insertions(+), 18 deletions(-) rename TangDou/LuoGuBook/{TestC.cpp => JinKuang.cpp} (100%) delete mode 100644 TangDou/LuoGuBook/TestBC.cpp create mode 100644 TangDou/LuoGuBook/ZhiMuSanJiaoXing.cpp create mode 100644 TangDou/LuoGuBook/ZhiMuSanJiaoXing.in diff --git a/TangDou/LuoGuBook/TestC.cpp b/TangDou/LuoGuBook/JinKuang.cpp similarity index 100% rename from TangDou/LuoGuBook/TestC.cpp rename to TangDou/LuoGuBook/JinKuang.cpp diff --git a/TangDou/LuoGuBook/TestBC.cpp b/TangDou/LuoGuBook/TestBC.cpp deleted file mode 100644 index 13a566e..0000000 --- a/TangDou/LuoGuBook/TestBC.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -using namespace std; -int main() { - int n, d; - cin >> n >> d; - double x = 1.0 * n / d; - double pre = round(x); - cout << pre << "/1" << endl; - for (int i = 1; i <= d; i++) { - for (int j = 1; j <= n; j++) { - double cur = 1.0 * j / i; - if (abs(cur - x) >= abs(pre - x)) continue; - cout << j << "/" << i << endl; - pre = cur; - } - } - return 0; -} \ No newline at end of file diff --git a/TangDou/LuoGuBook/ZhiMuSanJiaoXing.cpp b/TangDou/LuoGuBook/ZhiMuSanJiaoXing.cpp new file mode 100644 index 0000000..6689132 --- /dev/null +++ b/TangDou/LuoGuBook/ZhiMuSanJiaoXing.cpp @@ -0,0 +1,75 @@ +#include +using std::sort; +using std::cin; +using std::cout; +using std::endl; +using std::string; + +int n, flag, axis; +string inStr, ans; +struct point { + int x, y; + char v; // value +}; +std::vector pt; +struct point inf; + +bool comp(const point &a, const point &b) { + if (a.v == b.v) { + return (a.x == b.x) ? (a.y < b.y) : (a.x < b.x); + } else { + return a.v < b.v; + } +} +int main() { + cin >> n >> inStr; + flag = 0, axis = 0; + for (register int count = 0; count < n; ++count) { + for (register int countB = 0; countB < count + 1; ++countB) { + point newPt; + newPt.v = inStr[flag]; + newPt.y = count; + newPt.x = axis + (countB << 1); + ++flag; + pt.push_back(newPt); + // used for debug + // cout<