Cod sursa(job #2904335)

Utilizator RaduIonescuRadu Ionescu RaduIonescu Data 17 mai 2022 23:17:10
Problema Farfurii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>

using namespace std;

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

long long n,k,x,i,aux;

int main()
{
    in>>n>>k;

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

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

    aux = n-(x*(x-1)/2-k)

    out<<aux<<" ";

    for( i = n; i > n-x; --i )
        if( i != aux )
            out<<i<<" ";

    return 0;
}