text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int& x : a) cin >> x;
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
for (int b : a) cout << b << ' ';
cout << '\n';
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T;
cin >> T;
while (T--) solve();
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[105];
int t;
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<int>());
for (int i = 0; i < n; i++) cout << a[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
for (long long i = n - 1; i >= 0; i--) cout << a[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n;
cin >> n;
vector<long long> a(n);
for (auto i = (0); i < (n); ++i) cin >> a[i];
sort((a).begin(), (a).end());
reverse((a).begin(), (a).end());
for (auto i = (0); i < (n); ++i) cout << a[i] << ' ';
cout << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
int n;
cin >> n;
vector<int> V(n);
for (int i = 1; i <= n; ++i) {
cin >> V[i - 1];
}
sort(V.begin(), V.end(), cmp);
for (int i = 1; i <= n; ++i) {
cout << V[i - 1] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<long long, long long> &a,
const pair<long long, long long> &b) {
return (a.second < b.second);
}
long long nod(long long n) {
string s = to_string(n);
return (long long)s.length();
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<long long>());
for (long long i = 0; i < n; i++) cout << a[i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 5;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long arr[n];
for (long long i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
reverse(arr, arr + n);
for (long long i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
const int maxn = 100 + 5;
int a[maxn];
int main() {
int T, n;
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (int i = 0; i < n; ++i) scanf("%d", a + i);
std::sort(a, a + n);
for (int i = n - 1; i >= 0; --i) {
if (i != n - 1) putchar(' ');
printf("%d", a[i]);
}
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int p;
cin >> p;
while (p--) {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
for (int i = n - 1; i >= 0; i--) {
cout << arr[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int t, n;
void nhap() {
ios_base::sync_with_stdio(0);
cin >> t;
}
int main() {
nhap();
for (int i = 1; i <= t; ++i) {
a.clear();
cin >> n;
int x;
for (int j = 1; j <= n; ++j) {
cin >> x;
a.push_back(x);
}
sort(a.begin(), a.end());
for (int i = a.size() - 1; i >= 0; --i) cout << a[i] << ' ';
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int i, x;
vector<int> a;
for (i = 0; i < n; i++) {
cin >> x;
a.push_back(x);
}
sort(a.begin(), a.end(), greater<int>());
for (i = 0; i < n; i++) cout << a[i] << " ";
cout << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int gcd(int m, int n) {
int r, t;
if (m < n) {
t = m;
m = n;
n = t;
}
while (n != 0) {
r = m % n;
m = n;
n = r;
}
return m;
}
int lcm(int m, int n, int r) {
int t;
t = m * n / r;
return t;
}
bool cmp(int a, int b) { return a > b; }
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[105];
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + 1 + n, cmp);
for (int i = 1; i <= n; i++) {
if (i == n)
cout << a[i] << endl;
else
cout << a[i] << ' ';
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void kaam() {
int n, ctr = 0, max = 0;
cin >> n;
int arr[n];
for (long long i = 0; i < n; i++) cin >> arr[i];
sort(arr, arr + n);
reverse(arr, arr + n);
for (long long i = 0; i < n; i++) cout << arr[i] << " ";
cout << endl;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) kaam();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t, n;
int a[105];
bool Check() {
for (int i = 1; i < n; i++)
for (int j = i + 1; j <= n; j++)
if (j - i == a[j] - a[i]) return false;
return true;
}
void Test() {
int i, j;
cin >> n;
for (i = 1; i <= n; i++) cin >> a[i];
while (!Check()) {
for (i = 1; i < n; i++)
for (j = i + 1; j <= n; j++)
if (j - i == a[j] - a[i]) swap(a[j], a[i]);
}
for (i = 1; i <= n; i++) cout << a[i] << ' ';
cout << '\n';
}
int main() {
cin >> t;
while (t--) Test();
return 0;
}
|
#include <bits/stdc++.h>
int a[2000], tmp[2000];
void gb(int s, int end) {
if (s < end) {
int mid = (s + end) / 2, i = s, j = mid + 1, k = s;
gb(s, mid);
gb(mid + 1, end);
while (i <= mid && j <= end) {
if (a[i] >= a[j])
tmp[k++] = a[i++];
else {
tmp[k++] = a[j++];
}
}
while (i <= mid) tmp[k++] = a[i++];
while (j <= end) tmp[k++] = a[j++];
for (i = s; i <= end; i++) a[i] = tmp[i];
}
}
int main() {
int n, m;
while (~scanf("%d", &n)) {
while (n--) {
int m;
scanf("%d", &m);
for (int i = 0; i < m; i++) {
scanf("%d", &a[i]);
}
gb(0, m - 1);
for (int i = 0; i < m; i++) printf("%d ", a[i]);
printf("\n");
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (int i = 0; i < n; i++) {
cout << a[n - i - 1] << " ";
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a, a + n);
for (int i = n - 1; i >= 0; --i) {
cout << a[i] << " ";
}
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> vec(n);
for (int i = 0; i < n; ++i) {
cin >> vec[i];
}
sort(vec.rbegin(), vec.rend());
for (auto x : vec) {
cout << x << ' ';
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < (int)n; ++i) cin >> v[i];
sort((v).begin(), (v).end());
for (int i = (int)n - 1; i >= 0; --i) cout << v[i] << " ";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<int>());
for (int i = 0; i < n; i++) cout << a[i] << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
reverse(a, a + n);
for (auto u : a) cout << u << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void test_case() {
int n;
cin >> n;
vector<int> a(n);
for (int i = int(0); i < int(n); i++) cin >> a[i];
sort(a.begin(), a.end());
for (int i = n - 1; i >= 0; i--) cout << a[i] << " ";
cout << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) test_case();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 4;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int q;
cin >> q;
while (q--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n, greater<int>());
for (int j = 0; j < n; j++) {
cout << a[j] << " ";
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, f = 0;
cin >> n;
int arr[n], pans[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
reverse(arr, arr + n);
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << "\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n, greater<int>());
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
std::vector<long long int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a.begin(), a.end());
for (int i = n - 1; i >= 0; --i) {
cout << a[i] << " ";
}
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int ara[n];
for (int i = 0; i < n; i++) cin >> ara[i];
sort(ara, ara + n);
for (int i = n - 1; i >= 0; i--) cout << ara[i] << ' ';
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long llinf = 1e18;
const long double eps = 1e-6;
const long long mod = 1e9 + 7;
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.rbegin(), a.rend());
for (int i = 0; i < n; i++) {
cout << a[i] << ' ';
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<long long>());
for (long long i = 0; i < n; i++) cout << a[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const unsigned int modval = 1e9 + 7;
unsigned long long binpow(unsigned long long a, unsigned long long b,
unsigned long long m) {
a %= m;
unsigned long long res = 1;
while (b > 0) {
if (b & 1) {
res = res * a % m;
}
a = a * a % m;
b >>= 1;
}
return res;
}
unsigned long long binpow(unsigned long long a, unsigned long long b) {
unsigned long long res = 1;
while (b > 0) {
if (b & 1) {
res *= a;
}
a *= a;
b >>= 1;
}
return res;
}
unsigned int gcd(unsigned int a, unsigned int b) {
if (a == 0) {
return b;
}
return gcd(b % a, a);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
unsigned int t, n, aux;
cin >> t;
while (t--) {
cin >> n;
priority_queue<unsigned int, vector<unsigned int>> nums;
while (n--) {
cin >> aux;
nums.push(aux);
}
while (!nums.empty()) {
cout << nums.top() << ' ';
nums.pop();
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int maxn = 100;
long long bin(long long a, long long b) {
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
int gcd(int a, int b, int &x, int &y) {
if (a == 0) {
x = 0;
y = 1;
return b;
}
int x1, y1;
int d = gcd(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return d;
}
long long fact(long long x) {
long long res = 1;
for (long long i = 1; i <= x; i++) res = (res * i) % mod;
return res;
}
long long bcof(long long x, long long y) {
return fact(x) * bin(fact(x - y) * fact(y) % mod, mod - 2) % mod;
}
vector<vector<long long> > adj;
vector<bool> vis(maxn);
vector<long long> comp;
void dfs(int v) {
vis[v] = true;
comp.push_back(v);
for (int u : adj[v])
if (!vis[u]) dfs(u);
}
void solve(long long n, long long &ans, long long &p) {
for (int i = 1; i <= n; i++) vis[i] = false;
for (long long i = 1; i <= n; i++) {
if (!vis[i]) {
dfs(i);
comp.clear();
ans++;
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t, n, m, i, j, k;
cin >> t;
while (t--) {
cin >> n;
int a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n, greater<int>());
for (i = 0; i < n; i++) cout << a[i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long LOVE = 1701;
const int her_birthday = 1503;
void KhanhNgok() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<int>());
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
cin >> t;
while (t--) KhanhNgok();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
int b[n];
for (int i = 1; i < n; i++) {
b[i] = a[i - 1];
}
b[0] = a[n - 1];
cout << b[0] << " ";
for (int i = 1; i < n; i++) {
cout << b[n - i] << " ";
}
cout << endl;
return;
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long arr[N], A[N], ARR[N];
bool visited[N] = {};
long long cnt[N] = {};
bool f, ff;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n && cin >> arr[i]; ++i)
;
if (n == 1) {
cout << arr[0] << endl;
continue;
}
sort(arr, arr + n);
for (int i = n - 1; i >= 0; i--) {
cout << arr[i] << ' ';
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t--) {
long long int n, i, j;
cin >> n;
long long int a[n];
for (i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
for (i = n - 1; i >= 0; i--) cout << a[i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
int a[1000];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n, [=](int a, int b) { return a > b; });
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200;
int arr[maxn];
bool cmp(int num1, int num2) { return num1 > num2; }
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n, cmp);
for (int i = 0; i < n; i++) {
if (i) cout << ' ';
cout << arr[i];
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, i, arr[100009];
cin >> t;
while (t--) {
cin >> n;
for (i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
for (i = n - 1; i >= 0; i--) {
cout << arr[i] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long p) {
if (a == 0) return 0;
long long res = 1;
a %= p;
while (b > 0) {
if (b & 1) res = (res * a) % p;
b >>= 1;
a = (a * a) % p;
}
return res;
}
int32_t main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long ar[n];
for (long long i = 0; i < n; i++) cin >> ar[i];
sort(ar, ar + n);
for (long long i = n - 1; i >= 0; i--) cout << ar[i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<int>());
for (int i = 0; i < n; i++) cout << a[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxnn = 1e6 + 7;
const long long mod = 1e9 + 7;
const int inf = 1e9 + 7;
const double eps = 1e-6;
const double pi = 3.14159265358979;
long long fun(long long x1, long long y1, long long x2, long long y2) {
return abs(x1 - x2) + abs(y1 - y2);
}
int check(long long a, long long b, long long c, long long d, long long i,
long long n) {
if ((c * (n - i - 1) - i * d) <= (b - a) &&
(b - a) <= (d * (n - i - 1) - i * c))
return 1;
else
return 0;
}
long long ksm(long long a, long long b) {
long long ans = 1ll;
while (b) {
if (b & 1) ans = (a * ans) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans % mod;
}
long long C(long long n, long long m) {
if (m == 0ll) return 1ll;
if (n < m) return 0ll;
if (m < 0ll) return 0ll;
if (n == m) return 1ll;
long long ans = 1ll;
for (long long i = 0; i < m; i++) {
ans = ans * (n - i) % mod;
ans = ans * ksm(i + 1ll, mod - 2ll) % mod;
}
return ans % mod;
}
string Manacher(string s) {
long long ans = 0ll;
long long n = (long long)s.size();
ans = (n - 1ll) * n / 2ll;
long long temp = 0ll;
string t = "$#";
for (int i = 0; i < s.size(); i++) {
t += s[i];
t += "#";
}
vector<int> p(t.size(), 0);
int mx = 0, id = 0, reCenter = 0, reLen = 0;
for (int i = 1; i < t.size(); i++) {
p[i] = mx > i ? min(mx - i, p[2 * id - i]) : 1;
while (t[i + p[i]] == t[i - p[i]]) p[i]++;
if (i + p[i] > mx) {
mx = i + p[i];
id = i;
}
if (p[i] > reLen) {
reLen = p[i];
reCenter = i;
}
if (p[i] > 2ll) {
temp += p[i] - 2ll;
printf("%c %d\n", t[i], p[i]);
}
}
ans -= temp;
cout << ans + 1ll << endl;
return s.substr((reCenter - reLen) / 2, reLen - 1);
}
struct jz {
long long a[62][62];
jz() { memset(a, 0ll, sizeof(a)); }
};
jz jzcf(jz x, jz y, int n) {
jz ans;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
for (int k = 0; k < n; k++)
ans.a[i][j] = (ans.a[i][j] + (x.a[i][k] * y.a[k][j] % mod)) % mod;
return ans;
}
jz jzjf(jz x, jz y, int n) {
jz ans;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
ans.a[i][j] = (x.a[i][j] - y.a[i][j] + mod) % mod;
}
}
return ans;
}
jz cf(jz x, jz y, int n) {
jz matrix1;
jz ans;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
matrix1.a[i][j] = y.a[i][j];
}
}
for (int k = 0; k < n; k++) {
for (int t = n; t < n * 2; t++) {
if ((t - k) == n) {
matrix1.a[k][t] = 1;
} else {
matrix1.a[k][t] = 0;
}
}
}
for (int k = 0; k < n; k++) {
if (matrix1.a[k][k] != 1) {
int bs = matrix1.a[k][k];
matrix1.a[k][k] = 1;
for (int p = k; p < n * 2; p++) {
matrix1.a[k][p] *= ksm(bs, mod - 2);
matrix1.a[k][p] %= mod;
}
}
for (int q = 0; q < n; q++) {
if (q != k) {
int bs = matrix1.a[q][k];
for (int p = 0; p < n * 2; p++) {
matrix1.a[q][p] =
(matrix1.a[q][p] - (bs * matrix1.a[k][p] % mod) + mod) % mod;
}
} else {
continue;
}
}
}
for (int x = 0; x < n; x++) {
for (int y = n; y < n * 2; y++) {
ans.a[x][y - n] = matrix1.a[x][y];
}
}
return jzcf(x, ans, n);
}
jz jzksm(jz temp, long long b, int n) {
jz ans;
for (int i = 0; i < n; i++) {
ans.a[i][i] = 1ll;
}
while (b) {
if (b & 1) ans = jzcf(ans, temp, n);
temp = jzcf(temp, temp, n);
b >>= 1;
}
return ans;
}
int a[maxnn];
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, a + n);
for (int i = n - 1; i >= 0; i--) {
printf("%d ", a[i]);
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t, n, m, a[200], p[200], j, f;
int main() {
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i] = -1 * a[i];
}
sort(a, a + n);
for (int i = 0; i < n; i++) cout << -1 * a[i] << ' ';
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, i;
cin >> t;
while (t--) {
cin >> n;
int x[n];
for (i = 0; i < n; i++) cin >> x[i];
sort(x, x + n);
for (i = n - 1; i >= 0; i--) cout << x[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n, greater<int>());
for (int i = 0; i < n; i++) cout << a[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[105], dp[105];
int main() {
int t;
cin >> t;
while (t--) {
vector<int> a;
vector<int> b;
a.clear(), b.clear();
int n;
cin >> n;
if (n == 1) {
int x;
cin >> x;
cout << x << endl;
continue;
}
for (int i = 0; i < n; i++) {
int x;
cin >> x;
a.push_back(x);
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
void sol() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.rbegin(), a.rend());
for (auto X : a) {
cout << X << " ";
}
cout << "\n";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
sol();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, i;
cin >> n;
int a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (i = n - 1; i >= 0; i--) {
cout << a[i] << " ";
}
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
return (a / gcd<T>(a, b) * b);
}
template <class T>
T add(T a, T b) {
return ((a) + (b)) % 1000000007;
}
template <class T>
T mul(T a, T b) {
return ((a % 1000000007) * (b % 1000000007)) % 1000000007;
}
long long fast_exp(long long base, long long exp) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1) res = (res * base) % 1000000007;
base = (base * base) % 1000000007;
exp /= 2;
}
return res % 1000000007;
}
void printa(long long a[], long long n) {
for (int i = 0; i < n; i++) cout << a[i] << " ";
cout << endl;
}
void printv(vector<long long> v) {
for (auto i = v.begin(); i != v.end(); i++) cout << (*i) << " ";
cout << endl;
}
void printmat(long long *arr, long long m, long long n) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) cout << (*((arr + i * n) + j)) << " ";
cout << endl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t = 1, k, l, n, m, x, y, z, j, minn = LLONG_MAX, maxx = LLONG_MIN,
a, b, c, d;
bool flag;
cin >> t;
while (t--) {
cin >> n;
long long a[n];
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<long long>());
printa(a, n);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = acos((long double)-1);
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long tc;
cin >> tc;
while (tc--) {
long long n;
cin >> n;
vector<long long> arr;
for (int i = (1); i <= (n); i++) {
long long x;
cin >> x;
arr.push_back(x);
}
sort((arr).begin(), (arr).end(), greater<long long>());
for (int i = (0); i <= (n - 1); i++) {
cout << arr[i] << " ";
}
cout << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int ara[111];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int i, j, k, l, m, n, t;
cin >> t;
while (t--) {
cin >> n;
for (i = 0; i < n; i++) cin >> ara[i];
sort(ara, ara + n);
for (i = n - 1; i >= 0; i--) cout << ara[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void bogo(vector<int>& a) {
for (int i = 0; i < a.size() - 1; i++) {
int biggest = i;
for (int j = i + 1; j < a.size(); j++)
if (a[biggest] < a[j]) biggest = j;
if (biggest != i) swap(a[i], a[biggest]);
}
}
int main(int argc, char** argv) {
int t = 0;
cin >> t;
for (int i = 0; i < t; i++) {
int n = 0;
cin >> n;
vector<int> a;
for (int j = 0; j < n; j++) {
int v = 0;
cin >> v;
a.push_back(v);
}
bogo(a);
for (auto v : a) cout << v << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long T;
cin >> T;
while (T--) {
long long n;
cin >> n;
vector<long long> A(n);
for (long long i = 0; i < n; i++) cin >> A[i];
sort(A.begin(), A.end(), greater<long long>());
for (long long i = 0; i < n; i++) cout << A[i] << " ";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
vector<int> v(n);
for (auto &it : v) scanf("%d", &it);
sort(v.begin(), v.end(), greater<int>());
for (auto it : v) printf("%d ", it);
printf("\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int a[1000];
int cmp(int a, int b) { return a > b; }
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + 1 + n, cmp);
for (int i = 1; i <= n; i++) printf("%d ", a[i]);
puts("");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int ar[n];
for (long long i = (0); i < (n); i++) cin >> ar[i];
sort(ar, ar + n, greater<int>());
for (long long i = (0); i < (n); i++) cout << ar[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int i = 0; i < n; i++) {
sort(arr, arr + n, greater<int>());
}
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n], i, j;
for (i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<int>());
for (i = 0; i < n; i++) cout << a[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
void test() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << endl;
}
int main() {
int t;
cin >> t;
while (t--) test();
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int j = 0; j < t; ++j) {
int n;
cin >> n;
int* arr = new int[n];
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
sort(arr, arr + n, greater<int>());
for (int i = 0; i < n; ++i) {
cout << arr[i] << ' ';
}
cout << endl;
delete[] arr;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n], diff[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
reverse(a, a + n);
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int t, n, a[105];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
reverse(a, a + n);
for (int i = 0; i < n; i++) cout << a[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
int A[N];
for (int i = 0; i < N; i++) cin >> A[i];
sort(A, A + N, greater<int>());
for (int i = 0; i < N; i++) cout << A[i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
void fasterIO() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
void fileIO() { freopen("in.txt", "r", stdin); }
int main() {
int t, e;
cin >> t;
while (t--) {
cin >> e;
int arr[e + 7];
for (int i = 1; i <= e; i++) {
cin >> arr[i];
}
bool ok = false;
while (true) {
if (e == 1)
break;
else if (ok == false) {
int c = 0;
for (int i = 1; i <= e - 1; i++) {
if (c > 0 && ok == false) break;
for (int j = i + 1; j <= e; j++) {
if ((i - arr[i]) != (j - arr[j])) {
ok = true;
} else {
c++;
ok = false;
swap(arr[i], arr[j]);
break;
}
}
}
} else if (ok) {
break;
}
}
for (int i = 1; i <= e; i++) {
cout << arr[i] << " ";
}
cout << '\n';
}
exit(0);
}
|
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) { return a.second != b.second; }
int main() {
int x;
cin >> x;
while (x--) {
int q;
cin >> q;
vector<int> vec;
for (int i = 1; i <= q; i++) {
int r;
cin >> r;
vec.push_back(r);
}
sort(vec.begin(), vec.end(), greater<int>());
for (int i = 0; i < vec.size(); i++) {
cout << vec[i] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n, i;
cin >> n;
int a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n, greater<int>());
for (i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
for (int i = n - 1; i >= 0; i--) cout << a[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
void show(int a[], int n) {
for (int i = n - 1; i >= 0; i--) cout << a[i] << " ";
}
int main() {
int t, n;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> n;
int a[n];
for (int j = 0; j < n; j++) {
cin >> a[j];
}
sort(a, a + n);
show(a, n);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a[105];
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
}
sort(a, a + n, greater<int>());
for (int i = 0; i < n; ++i) {
printf("%d ", a[i]);
}
printf("\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long min_val(long long a, long long b) {
if (a <= b)
return a;
else
return b;
}
long long max_val(long long a, long long b) {
if (a >= b)
return a;
else
return b;
}
long long abs(long long a, long long b) {
long long tmp = min_val(a, b);
if (tmp == a) {
return b - a;
} else
return a - b;
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n, greater<int>());
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T &a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
bool umax(T &a, T b) {
return a < b ? (a = b, true) : false;
}
template <typename T, typename U>
bool compare(T x, U y) {
return (abs(x - y) <= 1e-9);
}
void solve() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int a[n];
for (auto &x : a) cin >> x;
sort(a, a + n);
for (int i = n - 1; i >= 0; i--) cout << a[i] << " ";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
solve();
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int t, d[101];
bool comp(int a, int b) { return a > b; }
int main() {
scanf("%d", &t);
for (int i = 1; i <= t; i++) {
int n;
scanf("%d", &n);
for (int j = 1; j <= n; j++) scanf("%d", &d[j]);
sort(d + 1, d + n + 1, comp);
for (int j = 1; j <= n; j++) printf("%d ", d[j]);
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (auto& x : a) {
cin >> x;
}
sort(a.begin(), a.end(), greater<int>());
for (auto& x : a) {
cout << x << ' ';
}
cout << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin >> T;
for (int t = 0; t < T; t++) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n, i;
cin >> n;
long long a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (i = n - 1; i >= 0; i--) {
cout << a[i] << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int q;
cin >> q;
for (int r = 0; r < (int)(q); r++) {
int n;
int a[101];
vector<int> vec;
cin >> n;
for (int i = 0; i < (int)(n); i++) {
cin >> a[i];
vec.push_back(a[i]);
}
sort(vec.begin(), vec.end());
reverse(vec.begin(), vec.end());
for (int i = 0; i < (int)(n); i++) {
cout << vec[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ceiling(long long a, long long b) {
if (a % b == 0)
return (a / b);
else
return (a / b) + 1;
}
long long max3(long long a, long long b, long long c) {
return max(a, max(b, c));
}
long long min3(long long a, long long b, long long c) {
return min(a, min(b, c));
}
long long power(long long x, long long y) {
if (y == 0)
return 1;
else if (y % 2 == 0)
return power(x, y / 2) * power(x, y / 2);
else
return x * power(x, y / 2) * power(x, y / 2);
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long test;
cin >> test;
while (test--) {
long long n;
cin >> n;
long long a[n], val[n];
for (long long i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
reverse(a, a + n);
for (long long i = 0; i < n; i++) cout << a[i] << " ";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void CyBerForCe() {
long long n;
cin >> n;
vector<long long> v;
for (long long i = 0; i < n; i++) {
long long a;
cin >> a;
v.push_back(a);
}
sort(v.begin(), v.end(), greater<long long>());
for (auto i : v) cout << i << " ";
cout << "\n";
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
while (t--) CyBerForCe();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long qpow(long long n, long long k) {
long long ans = 1;
while (k > 0) {
if (k & 1) ans = ans * n;
n = n * n;
k >>= 1;
}
return ans;
}
long long INV(long long x) {
return x == 1 ? x : 1LL * (mod - mod / x) * INV(mod % x) % mod;
}
long long gcd(long long a, long long b) {
if (a < b) swap(a, b);
return a % b == 0 ? b : gcd(b, a % b);
}
const long long MAX = 1e6 + 10;
long long a[MAX];
long long b[MAX];
long long ans[MAX];
long long totol[MAX];
long long to[MAX];
void in(long long y) {
for (long long i = 1; i <= y; ++i) scanf("%lld", &a[i]);
}
void out(long long y) {
for (long long i = 1; i <= y; ++i) {
i == y ? printf("%lld\n", a[i]) : printf("%lld ", a[i]);
}
}
int main() {
long long n, k, m, sum, t, len, flag, x, y;
string s, d;
sum = 0;
x = 0;
t = 998244353;
cin >> n;
while (n--) {
cin >> m;
for (long long i = (1); i <= (m); ++i) cin >> a[i];
sort(a + 1, a + m + 1);
reverse(a + 1, a + m + 1);
for (long long i = (1); i <= (m); ++i) cout << a[i] << ' ';
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n;
cin >> t;
while (t--) {
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n, greater<int>());
for (int i = 0; i < n; i++) cout << a[i] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
bool cmp(int x, int y) { return x > y; }
int main() {
int t;
int n;
int a[105];
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, a + n, cmp);
for (int i = 0; i < n - 1; i++) {
printf("%d ", a[i]);
}
printf("%d\n", a[n - 1]);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, i;
cin >> n;
long long ara[n];
for (i = 0; i < n; i++) cin >> ara[i];
sort(ara, ara + n, greater<long long>());
cout << ara[0];
for (i = 1; i < n; i++) cout << " " << ara[i];
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> v;
for (int i = 0; i < n; i++) {
int temp;
cin >> temp;
v.push_back(temp);
}
sort(v.begin(), v.end());
for (int i = 0; i < n; i++) cout << v[n - i - 1] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
long long int a[n];
for (long long int i = 0; i < n; i++) cin >> a[i];
long long int f = 0;
while (2) {
f = 0;
for (long long int i = 0; i < n; i++) {
for (long long int j = i + 1; j < n; j++) {
if (i - a[i] == j - a[j]) {
f = 1;
reverse(a + i, a + j + 1);
break;
}
}
if (f == 1) break;
}
if (f == 0) break;
}
for (long long int i = 0; i < n; i++) cout << a[i] << " ";
cout << "\n";
}
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, i, j;
cin >> n;
vector<int> v;
for (i = 0; i < n; i++) cin >> j, v.push_back(j);
sort(v.begin(), v.end());
while (n--) {
cout << v[n] << ' ';
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
srand(time(NULL));
;
long long t, n, m;
cin >> t;
while (t--) {
cin >> n;
vector<long long> v(n);
for (long long i = 0; i < n; i++) cin >> v[i];
sort(v.begin(), v.end());
for (long long i = n - 1; i >= 0; i--) cout << v[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << '\n';
err(++it, args...);
}
const long long mod = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int arr[n];
for (__typeof(n) i = (0) - (0 > n); i != (n) - (0 > n);
i += 1 - 2 * (0 > n))
cin >> arr[i];
sort(arr, arr + n, greater<int>());
for (__typeof(n) i = (0) - (0 > n); i != (n) - (0 > n);
i += 1 - 2 * (0 > n))
cout << arr[i] << ' ';
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
vector<vector<int>> out;
for (int i = 0; i < t; i++) {
int n;
cin >> n;
vector<int> a(n);
for (int j = 0; j < n; j++) cin >> a[j];
sort(a.begin(), a.end());
vector<int> o(n);
for (int j = n - 1; j >= 0; j--) o[j] = a[n - 1 - j];
out.push_back(o);
}
for (int i = 0; i < t; i++) {
for (int j = 0; j < out[i].size(); j++) cout << out[i][j] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
int main() {
ios_base::sync_with_stdio(false);
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
sort(v.begin(), v.end(), greater<int>());
for (auto at : v) cout << at << ' ';
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int T, n, m;
int a[N];
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
sort(a + 1, a + 1 + n);
for (int i = n; i >= 1; --i) printf("%d ", a[i]);
puts("");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
vector<int> arr;
for (int i = 0; i < N; i++) {
int x;
cin >> x;
arr.push_back(x);
}
sort(arr.begin(), arr.end(), greater<int>());
for (int i = 0; i < N; i++) {
cout << arr[i] << " ";
}
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
long long int a[n];
for (long long int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
for (long long int i = n - 1; i >= 0; i--) cout << a[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline void fastio() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
}
int main() {
fastio();
long long t;
cin >> t;
while (t--) {
long long n, i;
cin >> n;
long long a[n];
for (i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
reverse(a, a + n);
for (i = 0; i < n; i++) cout << a[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int n;
int a[MAXN];
void solve() {
cin >> n;
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, a + n);
reverse(a, a + n);
for (int i = 0; i < n; i++) {
printf("%d ", a[i]);
}
cout << endl;
}
int main() {
int tn;
scanf("%d\n", &tn);
while (tn--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[105], b[105], c[205];
int n;
int main() {
int t;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
sort(a + 1, a + 1 + n);
for (int i = n; i >= 1; i--) {
printf("%d ", a[i]);
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
for (long long i = n - 1; i >= 0; i--) cout << a[i] << " ";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 998244353ll;
const long long INF = 1e18;
const int MX = 2000000001;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
long long t, q, n, a, b, c, k = 0, second, l, m, r, x = 0, y = 0, z, sum = 0,
ans = 0, temp = 0, res = 0;
cin >> t;
while (t--) {
cin >> n;
vector<long long> v(n);
for (long long i = 0; i < (n); i++) cin >> v[i];
sort(v.begin(), v.end(), greater<long long>());
for (long long i = 0; i < (n); i++) cout << v[i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
void printVec(vector<T> v) {
for (int i = 0; i < v.size(); i++) {
cout << v[i] << " ";
}
cout << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> vals(n);
for (int i = 0; i < n; i++) {
cin >> vals[i];
}
sort(vals.begin(), vals.end());
reverse(vals.begin(), vals.end());
for (int i = 0; i < n; i++) {
cout << vals[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool doable;
int main() {
int t, n, m, temp;
cin >> t;
vector<int> V;
for (int i = 0; i < t; i++) {
V.clear();
cin >> n;
for (int j = 0; j < n; j++) {
cin >> m;
V.push_back(m);
}
sort(V.begin(), V.end());
reverse(V.begin(), V.end());
for (int j = 0; j < n; j++) {
cout << V[j] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename U>
U mini(U a, U b, U c) {
return (a > ((b > c) ? c : b)) ? ((b > c) ? c : b) : a;
}
long long M = 1000 * 1000 * 1000 + 7;
const long long N = 100005;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t = 1;
cin >> t;
while (t--) {
long long n, i, j, k, ans = 0, sum = 0;
cin >> n;
vector<long long> v;
for (i = 0; i < n; i++) {
cin >> k;
v.push_back(k);
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
for (i = 0; i < n; i++) cout << v[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int read() {
int f = 1, x = 0;
char c = getchar();
while (c < '0' || '9' < c) {
if (c == '-') f = -1;
c = getchar();
}
while ('0' <= c && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return f * x;
}
int a[100000 + 5];
bool cmp(int x, int y) { return x > y; }
int main() {
int T = read();
while (T--) {
int n = read();
for (int i = 1; i <= n; i++) a[i] = read();
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i++)
printf("%d", a[i]), putchar(i == n ? '\n' : ' ');
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T InvMod(T a, T b, T &x, T &y) {
if (a == 0) {
x = 0;
y = 1;
return b;
}
T x1, y1;
T g = InvMod(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return g;
}
long long fact(long long n) {
if (n == 1) return 1;
return (n % 1000000007 * fact(n - 1) % 1000000007) % 1000000007;
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
long long arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
sort(arr, arr + n, greater<int>());
for (int i = 0; i < n; i++) cout << arr[i] << " ";
cout << endl;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.