class Solution {
public:
vector<string> simplifiedFractions(int n) {
vector<string> ans;
for(int y=2;y<=n;y++){
for(int x=1;x<y;x++){
if(__gcd(x,y)==1){
ans.push_back(to_string(x)+'/'+to_string(y));
}
}
}
return ans;
}
};
to_string()系列函数将数值转换成字符串形式
最新推荐文章于 2022-08-22 16:15:28 发布