add: 220210-CN
This commit is contained in:
parent
37372e4c1b
commit
5ea3532fd5
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
|
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<std::string> simplifiedFractions(int n) {
|
||||||
|
std::vector<std::string> 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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -3,4 +3,4 @@ PROJECT(2202)
|
||||||
|
|
||||||
SET(CMAKE_CXX_STANDARD 23)
|
SET(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
ADD_EXECUTABLE(2202 220209-CN.cpp)
|
ADD_EXECUTABLE(2202 220210-CN.cpp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue