Cod sursa(job #2904783)
Utilizator | Beniamin Vasile memita | Data | 18 mai 2022 01:41:27 |
---|---|---|---|
Problema | Farfurii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
int main()
{
long long n, k, x = 1, i, aux;
fin >> n >> k;
while (x*(x+1)/2 <= k)
x++;
for (i = 1; i <= n-x-1; i++)
fout << i << ' ';
aux = n-(x * (x+1) / 2 - k);
fout << aux << ' ';
for (i = n; i >= n - x; i--)
if (i != aux)
fout << i << ' ';
return 0;
}