#include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> int main(){ int n; scanf("%d",&n); // your code goes here int num[n-1][n-1]; int sort(int m,int p,int t); for (int i=0;i<n-1;i++){ for (int j=0;j<i;j++){ num[j][i]=num[i][j]=sort(i+1,j+1,n-1); } } for (int h=0;h<n-1;h++){ for (int k=0;k<n-1;k++){ printf("%d ",num[h][k]); } printf("\n"); } return 0; } int sort(int m,int p,int t){ int step=0; int f; if (m==t&&p==t){ return t; } if (m>t/2&&p>t/2){ return -1; } while(m!=t&&p!=t){ if (p+p<=t){ p+=p; } else { p-=p; } step++; m+=m; } if (p==t){ return step+1; } else{ while(p!=t){ if (m+p<=t){ m+=p; } else { m-=p; } step++; p+=m; } return step+1; } }