Pagini recente » Cod sursa (job #812504) | Cod sursa (job #1177726) | Cod sursa (job #631211) | Cod sursa (job #1205025) | Cod sursa (job #529238)
Cod sursa(job #529238)
#include <fstream>
using namespace std;
int N, K;
int V[100002], can, num;
int main()
{
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
fin >> N >> K;
int 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();
}