Cod sursa(job #2755655)

Utilizator lolotbogdanLolot Stefan-Bogdan lolotbogdan Data 27 mai 2021 22:20:14
Problema Farfurii Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <iostream>
#include <fstream>

using namespace std;

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

int n, k, x, y, i;

int main()
{
    f >> n >> k;
    while(x * (x - 1) / 2 < k)
        x++;
    for(i = 1; i <= n - x; i++)
        g << i << " ";
    y = n - ((x * (x-1)) / 2 - k);
    g << y;
    for(i = n; i > n - y; i--)
        if(i != y)
            g <<" "<<i;

    return 0;
}