Cod sursa(job #1533707)

Utilizator toniobFMI - Barbalau Antonio toniob Data 22 noiembrie 2015 21:25:30
Problema Farfurii Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream>
#include <iostream>
using namespace std;

ifstream in("farfurii.in");
ofstream out("farfurii.out");

int n, k;

int main() {

	in >> n >> k;

	long long x = 1;
	while (x * (x - 1) / 2 < k) ++x;

	long long nr = (long long)n + k - x * (x - 1) / 2;

	for (int i = 1; i <= n - x; out << i++ << " ");

	out << nr << " ";
	for (int i = n; i > n - x; --i) {
		if (i != nr) {
			out << i << " ";
		}
	}

	return 0;
}