initial commit
This commit is contained in:
parent
1d4c29a367
commit
3fe7d6afe5
39
1828A Divisible Array/1828A.cpp
Normal file
39
1828A Divisible Array/1828A.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user