Title:
solution:
Let x be the number of wins and y be the number of draws, because all teams have the same score, then: x + y = n ∗ (n − 1) 2, 3 x + 2 y = kn, the solution is: x = n ∗ (k − N + 1), y = n ∗ (3 n − 3 2 − k), when n is an odd number, let k = 3 n − 3 2, then the number of draws is the least, that is, each team wins n − 1 2 When n is an even number, let k = 3 n − 4 2, at this time the number of draws is the least, that is, each team wins n − 2 2 times and draws 1 time. Let x be the number of wins and y be The number of draws, because all teams have the same score, \\ then has: x+y=\frac(n*(n-1))(2),3x+2y=kn,\\ solution: x=n*(k -n+1),y=n*(\frac{3n-3}{2}-k),\\ When n is an odd number, let k=\frac{3n-3}{2}, then draw The least number of times, \\ means that each team wins \frac{n-1}{2} times and draws 0 times. \\ When n is an even number, let k=\frac{3n-4}{2}, at this time The number of draws is the least, \\ means that each team wins \frac(n-2)(2) times and draws 1 time. Set x to win benefit times the number ,y is flat Bureau times the number ,Due to that there are teams divided number with the same ,That it has:x+Y=2n∗(n−1),3 x+2 y=kn,Solutions have to:x=n∗(k−n+1),Y=n∗(23 n−3−k),When n is an odd number when ,Let k=23 n−3,This time flat Bureau times the number of most small ,That is, each branch team Wu Sheng Lee2n−1Times ,Ping Bureau 0 times .When n is an even number of the time ,Let k=23 n−4,This time flat Bureau times the number of most small ,That is, each branch team Wu Sheng Lee2n−2Times ,Ping Board 1 times .
code:
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n;
void solve(){
cin>>n;
if(n%2==1){
int win=(n-1)/2;
for(int i=1;i<=n;i++){
int cnt=0;
for(int j=i+1;j<=n;j++){
cnt++;
if(cnt<=win)cout<<1<<' ';
else cout<<-1<<' ';
}
}
}else{
int win=(n-2)/2;
for(int i=1;i<=n;i++){
int cnt=0;
for(int j=i+1;j<=n;j++){
cnt++;
if(cnt<=win)cout<<1<<' ';
else if(cnt==win+1)cout<<0<<' ';
else cout<<-1<<' ';
}
}
}
cout<<endl;
}
signed main(){
ios::sync_with_stdio(0);
int T;cin>>T;
while(T--){
solve();
}
return 0;
}