Codeforces-SolutionsA/Codes/1828 A - Divisible Array/1828A.cpp

39 lines
570 B
C++
Raw Normal View History

2023-07-14 03:31:22 +08:00
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
int n;
cin>>n;
int a[n+1];
int sum = 0;
for (int i = 1; i <= n; ++i)
{
a[i] = i ;
sum = sum + i;
}
cerr<<sum<<" "<<n<<endl;
if(sum%n!=0)
{
int r=sum%n;
a[r]=a[r]+r;
}
for(int i=1; i<=n ; ++i)
{
cout<<a[i]<<" ";
}
cout<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TC = 1;
cin >> TC;
cin.ignore();
while (TC--)
solve();
}