Cod sursa(job #3341922)
| Utilizator | Data | 21 februarie 2026 16:41:58 | |
|---|---|---|---|
| Problema | Farfurii | Scor | 80 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <bits/stdc++.h>
using namespace std;
int main()
{
#ifndef LOCAL
freopen("farfurii.in", "r", stdin);
freopen("farfurii.out", "w", stdout);
#endif
long long n, i, nr;
long long k, x;
cin >> n >> k;
///cel mai mare x a.i. x * (x - 1) / 2 <= k.
x = sqrt(2 * k + 1) + 1;
//printf("%d ",x);
for(i = 1; i <= n - x; i++)
{
cout << i << " ";
}
nr = n - (x * (x - 1) * 1LL / 2 - k);
cout << nr << " ";
for(i = n; i > n - x; i--)
{
if(i != nr)
{
cout << i << " ";
}
}
return 0;
}