Pagini recente » Cod sursa (job #645955) | Cod sursa (job #2181093) | Cod sursa (job #1945010) | Cod sursa (job #3199317) | Cod sursa (job #2752166)
#include <fstream>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
int main() {
int N;
long long R;
fin >> N >> R;
long long x = 1;
while (x * (x + 1) / 2 <= R)
x++;
for (int i = 1; i <= N - x - 1; i++) {
fout << i << " ";
}
long long nr = N + R - x * (x + 1) / 2;
fout << nr << " ";
for (int i = N; i >= N - x ; i--) {
if (i != nr)
fout << i << " ";
}
}