diff --git a/2202/220210-CN.cpp b/2202/220210-CN.cpp new file mode 100644 index 0000000..b64aca6 --- /dev/null +++ b/2202/220210-CN.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + +class Solution { +private: + inline static std::string genStr(int x, int y) { + return std::to_string(x) + "/" + std::to_string(y); + } +public: + static std::vector simplifiedFractions(int n) { + std::vector ret; + for (int i = 2; i < n; ++i) + for (int j = 1; j < i; ++j) + if (1 == std::gcd(i, j)) + ret.push_back(genStr(j, i)); + return ret; + } +}; \ No newline at end of file diff --git a/2202/CMakeLists.txt b/2202/CMakeLists.txt index 8f76748..4250bd9 100644 --- a/2202/CMakeLists.txt +++ b/2202/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2202) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2202 220209-CN.cpp) +ADD_EXECUTABLE(2202 220210-CN.cpp)