|
- #include<iostream>
- #include<algorithm>
- using namespace std;
- int n,num;
- struct ss
- {
- int x,y;
- }s[10001];
- int gcd(int a,int b)
- {
- return b?gcd(b,a%b):a;
- }
- bool operator< (ss p,ss q)
- {
- return p.x*q.y<p.y*q.x;
- }
- int main()
- {
- cin>>n;
- cout<<"0/1"<<endl;
- for(int i=1;i<=n;i++)
- for(int j=1;j<i;j++)
- {
- if(gcd(i,j)==1)
- {
- s[++num].x=j;
- s[num].y=i;
- }
- }
- sort(s+1,s+num+1);
- for(int i=1;i<=num;i++)
- cout<<s[i].x<<'/'<<s[i].y<<endl;
- cout<<"1/1"<<endl;
- return 0;
- }
复制代码 |
|