1 solutions
-
0
#include<bits/stdc++.h> using namespace std; struct fenshu{ int fenzi; int fenmu; double zhi; }f[10001]; int cmp(fenshu a,fenshu b) { return a.zhi<b.zhi; } int main() { int n; cin>>n; cout<<"0/1"<<endl; int start=1; for(int i=1;i<=n;i++) { for(int j=i;j<=n;j++) { if(i<j&&gcd(i,j)==1) { f[start].fenzi=i; f[start].fenmu=j; f[start].zhi=double(i/1.0)/double(j/1.0); start++; } } } sort(f+1,f+start,cmp); for(int i=1;i<start;i++) { cout<<f[i].fenzi<<"/"<<f[i].fenmu<<endl; } cout<<"1/1"; } //i<j 但是要算最大公约数是1
- 1
Information
- ID
- 126
- Time
- 1000ms
- Memory
- 125MiB
- Difficulty
- 10
- Tags
- # Submissions
- 1
- Accepted
- 1
- Uploaded By