/* TASK: frac1 LANG: C++ URL: http://train.usaco.org/usacoprob2?S=frac1&a=dbgwn5v2WLr SOLVE: 直接枚举,约分,排序,去重 */ #include<cstdio> #include<algorithm> using namespace std; struct node{ int nu,deno; double v; }a[40000]; int n,cnt; int cmp(node a,node b){ return a.v<b.v; } int gcd(int a,int b){ return b?gcd(b,a%b):a; } int main(){ freopen("frac1.in","r",stdin); freopen("frac1.out","w",stdout); scanf("%d",&n); for(int i=0;i<=n;i++) for(int j=max(i,1);j<=n;j++){ int g=gcd(i,j); a[cnt++]=(node){i/g,j/g,i*1.0/j}; } sort(a,a+cnt,cmp); for(int i=0;i<cnt;i++){ if(i==0||a[i].v-a[i-1].v>1e-6||a[i].v-a[i-1].v<-1e-6) printf("%d/%d\n",a[i].nu,a[i].deno); } return 0; }
┆凉┆暖┆降┆等┆幸┆我┆我┆里┆将┆ ┆可┆有┆谦┆戮┆那┆ ┆大┆始┆ ┆然┆
┆薄┆一┆临┆你┆的┆还┆没┆ ┆来┆ ┆是┆来┆逊┆没┆些┆ ┆雁┆终┆ ┆而┆
┆ ┆暖┆ ┆如┆地┆站┆有┆ ┆也┆ ┆我┆ ┆的┆有┆精┆ ┆也┆没┆ ┆你┆
┆ ┆这┆ ┆试┆方┆在┆逃┆ ┆会┆ ┆在┆ ┆清┆来┆准┆ ┆没┆有┆ ┆没┆
┆ ┆生┆ ┆探┆ ┆最┆避┆ ┆在┆ ┆这┆ ┆晨┆ ┆的┆ ┆有┆来┆ ┆有┆
┆ ┆之┆ ┆般┆ ┆不┆ ┆ ┆这┆ ┆里┆ ┆没┆ ┆杀┆ ┆来┆ ┆ ┆来┆