Pagini recente » Cod sursa (job #1445786) | Cod sursa (job #466213) | Cod sursa (job #1967461) | Cod sursa (job #733260) | Cod sursa (job #529243)
Cod sursa(job #529243)
#include <fstream>
using namespace std;
long long N, K;
int V[100002], can, num;
int main()
{
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
fin >> N >> K;
long long posm;
for (posm = 1; posm * (posm + 1) / 2 <= K; ++posm);
--posm;
K -= posm * (posm + 1) / 2;
posm = N - posm;
int before = posm - 1 + K;
for (int i = 1; i <= posm - 2; ++i)
fout << i << ' ';
if (posm != 1) fout << before << ' ';
fout << N << ' ';
for (int i = N - 1; i >= posm - 1; --i)
if (i != before)
fout << i << ' ';
fin.close();
fout.close();
}