题解
2025-08-13 09:11:44
发布于:浙江
1阅读
0回复
0点赞
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int n;
map<double,string,less<double>> ha;
bool isvalid(int a,int b){
return __gcd(a,b)==1 && a<=b && 1<=b && b<=n;
}
int main(){
cin>>n;
for (int i=0;i<=n;i++){
for(int j=1;j<=n;j++){
if (isvalid(i,j)){
string str=to_string(i);
str.push_back('/');
str+=to_string(j);
ha[i*1./j]=str;
}
}
}
for (auto pr:ha) cout<<pr.second<<endl;
return 0;
}
这里空空如也
有帮助,赞一个